:root {
    --bg: #fffdfb;
    --bg-warm: #fdfbf7;
    --bg-cream: #fffaf2;
    --fg: #000000;
    --muted: #666666;
    --border: #e8e2d8;
    --border-dark: #e1d9cf;
    --radius: 8px;
    --header-font: 'Instrument Serif', serif;
    --body-font: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--body-font);
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

/* Hide scrollbar */
body::-webkit-scrollbar {
    display: none;
}

body {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Background Design - Warm minimal approach */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #f7f5f1 0%, #ffffff 100%);
    z-index: -1;
}

/* Typography */
h1, h2, h3, h4 {
    font-family: var(--header-font);
    font-weight: 400;
    color: var(--fg);
    line-height: 1.1;
}

h1 { font-size: clamp(2.5rem, 5vw, 4rem); letter-spacing: -0.02em; }
h2 { font-size: 2rem; margin-bottom: 1rem; }
h3 { font-size: 1.5rem; margin-bottom: 0.5rem; }

p { color: var(--muted); margin-bottom: 1rem; }
a { color: var(--fg); text-decoration: none; transition: opacity 0.2s; }
a:hover { opacity: 0.7; }

/* Layout & Containers */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Navigation */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    margin-bottom: 1.5rem;
}

.logo {
    font-family: var(--header-font);
    font-size: 1.5rem;
    font-style: italic;
    color: var(--fg);
    font-weight: 400;
}

.nav-links {
    display: flex;
    gap: 1.75rem;
    align-items: center;
}

.nav-links a {
    font-size: 0.95rem;
    font-weight: 500;
}

.btn-login, .btn-primary {
    background: var(--fg);
    color: var(--bg);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-login:hover, .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    color: var(--bg);
}

.btn-login:disabled, .btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--bg);
    border: 1px solid var(--border-dark);
    color: var(--fg);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    border-color: var(--fg);
    background: var(--bg-warm);
}

/* Hero & Landing */
.hero {
    padding: 2rem 0 4rem;
    display: flex;
    align-items: center;
    gap: 4rem;
}

.hero-content {
    flex: 1;
    max-width: 600px;
}

.hero h1 {
    margin-bottom: 1.5rem;
}

.hero p {
    font-size: 1.2rem;
    margin-bottom: 3rem;
}

.hero-image {
    flex: 1;
    max-width: 500px;
    height: auto;
    object-fit: contain;
}

.cta-form {
    display: flex;
    gap: 0.75rem;
    max-width: 500px;
}

.cta-form input {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s ease;
    background: var(--bg);
}

.cta-form input:focus {
    border-color: var(--fg);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.cta-form button {
    white-space: nowrap;
    background: var(--fg);
    color: var(--bg);
    border: none;
    padding: 0.875rem 1.75rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    font-family: var(--body-font);
}

.cta-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Features Grid */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4rem;
    padding: 6rem 0;
    border-top: 1px solid var(--border);
}

.feature-item h3 {
    margin-bottom: 0.75rem;
}

/* Footer */
footer {
    display: flex;
    justify-content: space-between;
    padding: 3rem 0 2rem;
    margin-top: 6rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--muted);
}

/* Login Page specific */
.login-container {
    min-height: 75vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 0;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 3rem 2.5rem;
    background: var(--bg-warm);
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.form-group { margin-bottom: 1.75rem; }
.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.625rem;
    color: var(--fg);
}
.form-group input, .form-group textarea {
    width: 100%;
    padding: 0.875rem 1.125rem;
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    background: var(--bg);
    transition: all 0.2s ease;
}
.form-group input:focus, .form-group textarea:focus {
    border-color: var(--fg);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

/* Custom file input styling */
#materialFiles {
    padding: 0.6rem 0.9rem;
    cursor: pointer;
}

#materialFiles::file-selector-button {
    border: 1px solid var(--border-dark);
    background: transparent;
    color: var(--fg);
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    margin-right: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

#materialFiles::file-selector-button:hover {
    background: var(--fg);
    color: var(--bg);
}


/* Sponsor Page */
.sponsor-hero {
    text-align: center;
    padding: 3rem 0 4rem;
    max-width: 700px;
    margin: 0 auto;
}

.sponsor-hero h1 {
    margin-bottom: 1.25rem;
    font-size: 3rem;
}

.sponsor-hero p {
    font-size: 1.1rem;
    line-height: 1.6;
}

.sponsor-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-bottom: 5rem;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.sponsor-card {
    padding: 2.5rem 2.25rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #ffffff;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.sponsor-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.04);
}

.sponsor-card.gold {
    background: linear-gradient(135deg, #fffaf2 0%, #ffffff 100%);
    border-color: #e1d5c2;
}

.sponsor-card.gold::before {
    content: "Guld";
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: #f1e4d1;
    color: #8c6d3f;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sponsor-card h2 {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.sponsor-price {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 1.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sponsor-features {
    list-style: none;
    margin-bottom: 2.5rem;
    flex-grow: 1;
}

.sponsor-features li {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
    font-size: 0.95rem;
    color: var(--muted);
    line-height: 1.4;
}

.sponsor-features li::before {
    content: "→";
    color: var(--fg);
    font-weight: 600;
    font-size: 0.9rem;
}

.sponsor-card .btn-primary {
    width: 100%;
    padding: 0.85rem;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .sponsor-grid {
        grid-template-columns: 1fr;
    }
    
    .sponsor-card {
        padding: 2rem 1.75rem;
    }
}

/* Dashboard specific */
.dashboard-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: calc(100vh - 200px);
    gap: 2.5rem;
    margin-top: 1rem;
    margin-bottom: 3rem;
}

.sidebar {
    padding-right: 1.5rem;
    border-right: 1px solid var(--border);
}

.sidebar-heading {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: 1rem;
    font-weight: 600;
}

.exam-list-item {
    display: block;
    padding: 1rem 1.125rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.625rem;
    transition: all 0.2s ease;
    background: var(--bg);
}
.exam-list-item:hover {
    border-color: var(--border-dark);
    background: var(--bg-warm);
    transform: translateX(2px);
}
.exam-list-item h4 {
    font-family: var(--body-font);
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    color: var(--fg);
}
.exam-list-item span {
    font-size: 0.8rem;
    color: var(--muted);
}

.main-content {
    padding: 0;
}

.create-exam-section {
    position: relative;
    padding: 3.5rem 3rem;
    background: linear-gradient(135deg, var(--bg-warm) 0%, #ffffff 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    overflow: hidden;
}

.create-exam-section::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 85% 15%, rgba(255,255,255,0.7), transparent 40%),
        radial-gradient(circle at 10% 80%, rgba(255,255,255,0.5), transparent 35%),
        repeating-linear-gradient(
            0deg,
            rgba(120, 110, 100, 0.02),
            rgba(120, 110, 100, 0.02) 1px,
            transparent 1px,
            transparent 32px
        );
    opacity: 0.7;
    pointer-events: none;
}

.create-exam-section h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    position: relative;
}

.create-exam-section p {
    font-size: 1.15rem;
    margin-bottom: 2.5rem;
    color: var(--muted);
    position: relative;
}

.create-exam-section button {
    position: relative;
}

.empty-state {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--muted);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal.show { display: flex; }

.modal-content {
    background: var(--bg-warm);
    width: 100%;
    max-width: 540px;
    padding: 2.5rem 2.25rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    position: relative;
    box-shadow: 0 32px 64px rgba(0,0,0,0.16);
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

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

.modal-content h2 {
    margin-bottom: 0.5rem;
}

.modal-content > p {
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.modal-close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--muted);
    transition: all 0.2s ease;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--fg);
    border-color: var(--border-dark);
    background: var(--bg-warm);
}

.difficulty-options {
    display: flex;
    gap: 0.75rem;
}
.difficulty-option {
    flex: 1;
    text-align: center;
    cursor: pointer;
}
.difficulty-option input { display: none; }
.difficulty-badge {
    display: block;
    padding: 0.875rem 0.5rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    background: var(--bg);
}
.difficulty-badge:hover {
    border-color: var(--border-dark);
    background: var(--bg-warm);
}
.difficulty-option input:checked + .difficulty-badge {
    background: var(--fg);
    color: var(--bg);
    border-color: var(--fg);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transform: translateY(-1px);
}

/* Exam Mode Options */
.exam-mode-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
.exam-mode-option {
    cursor: pointer;
    height: 100%;
}
.exam-mode-option input { display: none; }
.exam-mode-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.5rem 1.25rem;
    height: 100%;
    min-height: 110px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}
.exam-mode-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--fg);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.exam-mode-card:hover {
    border-color: var(--fg);
    background: var(--bg-warm);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.exam-mode-option input:checked + .exam-mode-card {
    background: var(--fg);
    color: var(--bg);
    border-color: var(--fg);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}
.exam-mode-option input:checked + .exam-mode-card::before {
    opacity: 1;
}
.exam-mode-title {
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.01em;
    line-height: 1.3;
}
.exam-mode-desc {
    font-size: 0.85rem;
    opacity: 0.7;
    line-height: 1.4;
    flex-grow: 1;
}

.error-message {
    color: #e11d48;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border-radius: 6px;
    border-left: 3px solid #e11d48;
    display: none;
}
.error-message.show { display: block; }

.material-header {
    margin-bottom: 0.5rem;
}

.material-subject {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.material-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 0.375rem;
}

.material-meta {
    font-size: 0.825rem;
    color: var(--muted);
}


/* Selected material info */
#selectedMaterialInfo {
    background: var(--bg-cream);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 0 auto 2.5rem;
    max-width: 420px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Inline exam creation flow */
.back-btn {
    border: none;
    padding: 0;
    margin: 0 0 2rem 0;
    font-size: 0.85rem;
    color: var(--muted);
    background: transparent;
    text-decoration: none;
    transition: color 0.2s ease;
}

.back-btn:hover {
    color: var(--fg);
    background: transparent;
    text-decoration: underline;
}

.create-exam-section > div {
    position: relative;
    z-index: 1;
}

.create-exam-section #step1,
.create-exam-section #step1b,
.create-exam-section #step2,
.create-exam-section #step3,
.create-exam-section #step4 {
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.create-exam-section #step1 h1,
.create-exam-section #step1b h1,
.create-exam-section #step2 h1,
.create-exam-section #step3 h1,
.create-exam-section #step4 h1 {
    text-align: center;
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
}

.create-exam-section #step1 > p,
.create-exam-section #step1b > p,
.create-exam-section #step2 > p,
.create-exam-section #step3 > p,
.create-exam-section #step4 > p {
    text-align: center;
    margin-bottom: 1.75rem;
    color: var(--muted);
    font-size: 0.95rem;
}

/* Materials grid */
.materials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.875rem;
    margin-bottom: 1.75rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

/* Center single material card */
.materials-grid:has(.material-card:only-of-type) {
    justify-items: center;
}

.materials-grid .material-card:only-of-type {
    max-width: 280px;
    width: 100%;
}

.materials-grid .empty-materials {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem 1.5rem;
    background: var(--bg-cream);
    border: 1px dashed var(--border);
    border-radius: 12px;
}

.materials-grid .empty-materials p {
    color: var(--muted);
    margin: 0;
    line-height: 1.6;
}

/* Material card improvements */
.material-card {
    padding: 1.125rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg);
}

.material-card:hover {
    border-color: var(--border-dark);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.material-card.selected {
    border-color: var(--fg);
    background: var(--bg-cream);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Inline form styling */
.inline-form {
    max-width: 420px;
    margin: 0 auto;
}

.inline-form .form-group {
    margin-bottom: 1.75rem;
}

.inline-form .form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.625rem;
    color: var(--fg);
}

.inline-form button[type="submit"] {
    margin-top: 1rem;
    width: 100%;
}

/* Create material button */
#createMaterialButton {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    font-size: 0.95rem;
    border: 1px dashed var(--border-dark);
    background: transparent;
    transition: all 0.2s ease;
    margin-left: auto;
    margin-right: auto;
    width: fit-content;
}

#createMaterialButton:hover {
    border-style: solid;
    border-color: var(--fg);
    background: var(--bg-warm);
}

#selectedMaterialInfo h3 {
    font-family: var(--body-font);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.875rem;
    color: var(--fg);
}

#selectedMaterialInfo p {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--muted);
    line-height: 1.5;
}

#selectedMaterialInfo p strong {
    color: var(--fg);
    font-weight: 500;
}

#selectedMaterialInfo p:last-child {
    margin-bottom: 0;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--muted);
    font-size: 0.95rem;
}

/* Materials container scrolling */
#materialsContainer {
    scrollbar-width: thin;
    scrollbar-color: var(--border-dark) transparent;
}

#materialsContainer::-webkit-scrollbar {
    width: 6px;
}

#materialsContainer::-webkit-scrollbar-track {
    background: transparent;
}

#materialsContainer::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 3px;
}

#materialsContainer::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

/* Responsive */
@media (max-width: 768px) {
    .hero {
        flex-direction: column;
        gap: 2rem;
        padding: 3rem 0 5rem;
    }

    .hero-content {
        max-width: 100%;
    }

    .hero-image {
        max-width: 350px;
        margin: 0 auto;
    }

    .features { grid-template-columns: 1fr; gap: 3rem; }
    .dashboard-layout { grid-template-columns: 1fr; gap: 2rem; }
    .sidebar {
        padding-right: 0;
        padding-bottom: 2rem;
        margin-bottom: 2rem;
        border-bottom: 1px solid var(--border);
    }
    .cta-form { flex-direction: column; }
    .modal-content { padding: 2rem 1.5rem; }
    .login-card { padding: 2rem 1.5rem; }
}

/* Exam loading overlay - clean and simple */
.exam-loading-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #f9f6f1 0%, #fffdfb 50%, #faf7f2 100%);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.exam-loading-overlay.show {
    display: flex;
}

.exam-loading-overlay .loading-container {
    text-align: center;
}

.exam-loading-overlay h1,
.exam-loading-overlay .loading-title {
    font-family: var(--header-font);
    font-size: 3rem;
    font-weight: 400;
    color: #000000;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
}

.exam-loading-overlay .subtitle,
.exam-loading-overlay .loading-subtitle {
    font-size: 0.95rem;
    font-weight: 300;
    color: #8b7d6b;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.exam-loading-overlay .dots,
.exam-loading-overlay .loading-dots {
    display: inline-flex;
    gap: 6px;
    margin-left: 8px;
}

.exam-loading-overlay .dots span,
.exam-loading-overlay .loading-dots span {
    width: 4px;
    height: 4px;
    background: #8b7d6b;
    border-radius: 50%;
    animation: loadingDotPulse 1.5s ease-in-out infinite;
}

.exam-loading-overlay .dots span:nth-child(1),
.exam-loading-overlay .loading-dots span:nth-child(1) { animation-delay: 0s; }
.exam-loading-overlay .dots span:nth-child(2),
.exam-loading-overlay .loading-dots span:nth-child(2) { animation-delay: 0.3s; }
.exam-loading-overlay .dots span:nth-child(3),
.exam-loading-overlay .loading-dots span:nth-child(3) { animation-delay: 0.6s; }

@keyframes loadingDotPulse {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.exam-loading-overlay .status,
.exam-loading-overlay .loading-step-counter {
    margin-top: 2rem;
    font-size: 0.85rem;
    color: #8b7d6b;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.exam-loading-overlay .progress-track {
    width: min(320px, 70vw);
    height: 2px;
    margin: 1.75rem auto 0;
    background: rgba(139, 125, 107, 0.2);
    border-radius: 999px;
    overflow: hidden;
}

.exam-loading-overlay .progress-bar {
    height: 100%;
    width: 100%;
    background: #8b7d6b;
    transform-origin: left center;
    animation: load 35s linear forwards;
}

@keyframes load {
    0% {
        transform: scaleX(0);
    }
    100% {
        transform: scaleX(1);
    }
}

/* Exam page */
.exam-page::before {
    background: linear-gradient(180deg, #f7f5f1 0%, #ffffff 100%);
}

.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.exam-meta-card {
    display: grid;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid #e6e1d9;
    border-radius: 12px;
    background: #fffaf2;
    min-width: 220px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.exam-meta-card div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.exam-meta-label {
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.exam-paper {
    position: relative;
    padding: 3rem 3.5rem;
    border-radius: 20px;
    border: 1px solid #e8e2d8;
    background: #fdfbf7;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-bottom: 3rem;
}

.exam-paper::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.7), transparent 45%),
        radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.7), transparent 40%),
        repeating-linear-gradient(
            0deg,
            rgba(120, 110, 100, 0.03),
            rgba(120, 110, 100, 0.03) 1px,
            transparent 1px,
            transparent 28px
        );
    opacity: 0.8;
    pointer-events: none;
}

.exam-intro,
.exam-content {
    position: relative;
    z-index: 1;
}

.exam-intro {
    margin-bottom: 2.5rem;
}

.exam-intro p {
    font-size: 1.05rem;
    color: var(--fg);
    margin-bottom: 1rem;
}

#examInstructions {
    padding-left: 1.25rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.exam-section {
    margin-bottom: 2.75rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px dashed #ded7cc;
}

.exam-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.section-header h2 {
    margin-bottom: 0.4rem;
}

.section-header p {
    color: var(--muted);
    margin-bottom: 1.25rem;
}

.exam-question {
    position: relative;
    margin-bottom: 2rem;
    padding: 1.5rem 1.5rem 1.75rem;
    border: 1px solid #ece6dd;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.question-number {
    font-size: 1rem;
}

.question-points {
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    position: absolute;
    right: 0.4rem;
    bottom: 0;
}

.question-context {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.question-prompt {
    margin-bottom: 1rem;
    font-family: var(--body-font);
    font-size: 1.05rem;
    font-weight: 600;
}

.question-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mc-options {
    display: grid;
    gap: 0.6rem;
}

.mc-options.lettered .mc-option {
    align-items: center;
}

.mc-letter {
    font-weight: 600;
    font-size: 0.85rem;
    color: #111111;
    width: 24px;
}

.mc-option {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #e8e2d8;
    background: #ffffff;
}

.mc-option input {
    accent-color: #1a1a1a;
}

.guidance-list {
    padding-left: 1.1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.question-content {
    flex: 1;
    min-width: 0;
}

.exam-question {
    position: relative;
    padding-bottom: 1.6rem;
}

.exam-question:has(.question-image) {
    display: flex;
    flex-direction: row;
    gap: 1.25rem;
    align-items: flex-start;
}

.question-image {
    width: 130px;
    height: auto;
    flex-shrink: 0;
    border-radius: 10px;
    border: 1px solid var(--border-dark);
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.long-answer {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #e1d9cf;
    padding: 0.75rem;
    font-family: var(--body-font);
    background: repeating-linear-gradient(
        #fffaf2 0px,
        #fffaf2 28px,
        #f4eee5 29px
    );
    resize: vertical;
}

.short-answer {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #e1d9cf;
    padding: 0.6rem 0.75rem;
    font-family: var(--body-font);
    background: #ffffff;
}

.multi-part {
    display: grid;
    gap: 1.1rem;
}

.multi-part-row {
    position: relative;
    padding: 0.75rem 0.9rem 1.6rem;
    border-radius: 10px;
    border: 1px dashed #e2dbd1;
    background: #fffdf8;
}

.multi-part-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: baseline;
    margin-bottom: 0.6rem;
    font-weight: 600;
}

.multi-part-label {
    font-weight: 700;
    color: #111111;
}

.multi-part-prompt {
    flex: 1;
    font-weight: 500;
}

.multi-part-points {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    position: absolute;
    right: 0.9rem;
    bottom: 0.6rem;
}

.matching-grid {
    display: grid;
    gap: 0.75rem;
}

.matching-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: center;
}

.matching-left {
    font-weight: 500;
}

.matching-select {
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #e1d9cf;
    background: #fff;
    font-family: var(--body-font);
}

.calc-givens {
    padding-left: 1.1rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.calc-formula {
    background: #f5efe6;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9rem;
    color: #2b2b2b;
}

.calc-work {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #e1d9cf;
    padding: 0.75rem;
    font-family: var(--body-font);
    background: #fffaf2;
    resize: vertical;
}

.calc-answer {
    width: 50%;
    min-width: 160px;
    border-radius: 8px;
    border: 1px solid #e1d9cf;
    padding: 0.6rem 0.75rem;
    font-family: var(--body-font);
    background: #ffffff;
}

.exam-error {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.exam-submit {
    margin-top: 2.5rem;
    padding: 1.5rem 1.75rem;
    border-radius: 14px;
    border: 1px dashed #e2dbd1;
    background: #fffaf2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
}

.exam-submit::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 160px;
    height: 100%;
    background: radial-gradient(circle at top right, rgba(0, 0, 0, 0.08), transparent 70%);
    opacity: 0.12;
    pointer-events: none;
}

.exam-submit-text h3 {
    margin-bottom: 0.35rem;
}

.exam-submit-text p {
    margin-bottom: 0;
}

/* Results page */
.results-page::before {
    background: linear-gradient(180deg, #f7f3ec 0%, #ffffff 100%);
}

.results-hero {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    margin: 1.5rem auto 3rem;
}

.results-hero-text {
    max-width: 680px;
}

.results-eyebrow {
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.7rem;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.score-card {
    width: 320px;
    padding: 1.75rem;
    border-radius: 18px;
    border: 1px solid #e8e2d8;
    background: #fffaf2;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.score-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top, rgba(0, 0, 0, 0.08), transparent 60%);
    opacity: 0.1;
    pointer-events: none;
}

.score-ring {
    width: 170px;
    height: 170px;
    border-radius: 50%;
    background: conic-gradient(var(--fg) calc(var(--score) * 1turn), #e7dfd4 0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: --score 1.2s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.score-ring-inner {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: inset 0 10px 25px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.score-value {
    font-family: var(--header-font);
    font-size: 2.1rem;
    letter-spacing: -0.02em;
}

.score-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--muted);
    margin-top: 0.2rem;
}

.score-meta {
    width: 100%;
    display: grid;
    gap: 0.65rem;
}

.score-meta div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.meta-label {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.65rem;
    color: var(--muted);
}

.result-steps {
    display: grid;
    gap: 2.5rem;
    margin-bottom: 3rem;
}

.result-step {
    padding: 2.25rem;
    border-radius: 22px;
    border: 1px solid #e8e2d8;
    background: #ffffff;
    box-shadow: 0 22px 50px rgba(0, 0, 0, 0.06);
}

.result-step-header {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.25rem;
    align-items: center;
    margin-bottom: 2rem;
}

.result-step-header p {
    margin-bottom: 0;
}

.result-step-index {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: #f4efe7;
    border: 1px solid #e6ded3;
    font-size: 0.9rem;
    letter-spacing: 0.18em;
    font-weight: 600;
}

.result-step-body {
    display: grid;
    grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
    gap: 2rem;
    align-items: stretch;
}

.result-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.75rem;
    align-items: stretch;
}

.result-card {
    padding: 1.4rem;
    border-radius: 16px;
    border: 1px solid #e8e2d8;
    background: #fffaf2;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(0, 0, 0, 0.06), transparent 55%);
    opacity: 0.2;
    pointer-events: none;
}

.result-list {
    list-style: none;
    display: grid;
    gap: 0.7rem;
    margin-top: 1rem;
}

.result-list li {
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    border: 1px solid #efe7dc;
    background: #ffffff;
    font-size: 0.9rem;
}

.result-questions {
    display: grid;
    gap: 1.5rem;
}

.result-question {
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid #ece6dd;
    background: #ffffff;
    box-shadow: 0 16px 35px rgba(0, 0, 0, 0.06);
}

.result-question-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.75rem;
}

.result-question-points {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.result-question-context {
    color: var(--muted);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.result-question-prompt {
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 0.9rem;
}

.result-answer {
    background: #fffaf2;
    border: 1px solid #eadfd4;
    border-radius: 12px;
    padding: 0.85rem 1rem;
    font-family: var(--body-font);
    white-space: pre-wrap;
    line-height: 1.55;
    margin-bottom: 0.75rem;
}

.result-feedback {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid #e7e1d7;
    background: #f7f4ef;
    font-size: 0.95rem;
}

.result-parts {
    margin-top: 1rem;
    display: grid;
    gap: 0.75rem;
}

.result-part {
    padding: 1rem;
    border-radius: 12px;
    border: 1px dashed #e2dbd1;
    background: #fffdf8;
}

.result-part-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.result-part-label {
    font-weight: 600;
}

.result-part-points {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.result-part-prompt {
    color: var(--muted);
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
}

.result-explanations {
    display: grid;
    gap: 1.25rem;
}

.result-explanation {
    padding: 1.6rem;
    border-radius: 18px;
    border: 1px solid #e8e2d8;
    background: linear-gradient(135deg, #fffaf2 0%, #ffffff 100%);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.06);
}

.result-explanation-body p {
    color: #3f3f3f;
}

.result-loading {
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: 2rem 2.5rem;
    margin: 2.5rem auto 1rem;
    color: var(--muted);
    font-size: 0.95rem;
    border-radius: 999px;
    border: 1px solid #ece6dd;
    background: #fffaf2;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.06);
    max-width: 560px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid #e7dfd4;
    border-top-color: #1f1f1f;
    animation: spin 0.9s linear infinite;
    flex: 0 0 auto;
}

.loading-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 0.3rem;
}

.loading-text span:first-child {
    font-weight: 600;
    color: var(--fg);
}

.loading-sub {
    font-size: 0.85rem;
    color: var(--muted);
}

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

@property --score {
    syntax: "<number>";
    inherits: false;
    initial-value: 0;
}

@media (max-width: 900px) {
    .exam-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .exam-meta-card {
        width: 100%;
    }

    .exam-paper {
        padding: 2.2rem 1.6rem;
    }

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

    .calc-answer {
        width: 100%;
    }

    .exam-submit {
        flex-direction: column;
        align-items: flex-start;
    }

    .exam-submit .btn-primary {
        width: 100%;
    }

    .results-hero {
        text-align: left;
        align-items: flex-start;
    }

    .score-card {
        width: 100%;
    }

    .result-step {
        padding: 1.75rem;
    }

    .result-step-header {
        grid-template-columns: 1fr;
    }

    .result-step-body {
        grid-template-columns: 1fr;
    }

    .result-summary {
        grid-template-columns: 1fr;
    }
}

/* ================================
   DIGITAL WORKSPACE COMPONENT
   ================================ */

.workspace-container {
    margin-top: 1rem;
    padding: 0.5rem 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    position: relative;
}

.workspace-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.workspace-label::before {
    content: "";
    display: block;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23666'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M4 20l4.5-1.2L19.5 7.8a2.1 2.1 0 0 0 0-3l-2.1-2.1a2.1 2.1 0 0 0-3 0L3.3 13.8 4 20z'/%3E%3C/svg%3E");
    background-size: contain;
}

.workspace-canvas {
    position: relative;
    min-height: 260px;
    border-radius: 10px;
    border: none;
    background: transparent;
    overflow: hidden;
    padding: 0.5rem 0;
}

.workspace-canvas.line-mode {
    cursor: crosshair;
}

.workspace-block {
    position: absolute;
    min-width: 0;
    max-width: 100%;
    padding: 0.15rem 0.2rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    box-shadow: none;
    color: var(--fg);
    cursor: text;
    z-index: 1;
}

.workspace-block.active {
    background: transparent;
    box-shadow: none;
    z-index: 2;
}

.workspace-block.is-dragging {
    cursor: grabbing;
    opacity: 0.95;
}

.workspace-block-math {
    min-height: 32px;
    outline: none;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    display: inline-block;
    max-width: 100%;
    min-width: 1ch;
    font-size: 1.2rem;
    line-height: 1.4;
    color: var(--fg);
    caret-color: var(--fg);
    --mlv-background-color: transparent;
    --mlv-border-color: transparent;
    --mlv-focus-border-color: transparent;
    --mlv-caret-color: var(--fg);
    --caret-color: var(--fg);
    --mlv-selection-background-color: rgba(0, 0, 0, 0.12);
    --mlv-selection-color: var(--fg);
    --mlv-primary-color: var(--fg);
    --mlv-secondary-color: rgba(0, 0, 0, 0.6);
    --selection-background-color: rgba(0, 0, 0, 0.12);
    --selection-color: var(--fg);
}

.workspace-block-math:focus {
    outline: none;
}

.workspace-block-math::part(virtual-keyboard-toggle) {
    display: none;
}

.workspace-block-math::part(caret) {
    background: var(--fg);
    border-color: var(--fg);
}

.workspace-block-math::part(menu-toggle),
.workspace-block-math::part(menu) {
    display: none;
}

.workspace-block[data-style="h1"] .workspace-block-math {
    font-size: 1.7rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.workspace-block[data-style="h2"] .workspace-block-math {
    font-size: 1.35rem;
    font-weight: 600;
}

.workspace-line {
    position: absolute;
    height: 2px;
    background: var(--fg);
    border-radius: 999px;
    transform-origin: 0 50%;
    cursor: grab;
    opacity: 0.9;
    pointer-events: none;
    z-index: 0;
}

.workspace-canvas.line-mode .workspace-line {
    pointer-events: auto;
}

.workspace-line.is-dragging {
    cursor: grabbing;
}

.workspace-block[data-bold="true"] .workspace-block-math {
    font-weight: 700;
}

.workspace-block[data-italic="true"] .workspace-block-math {
    font-style: italic;
}

.workspace-toolbar {
    position: absolute;
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.2rem 0.3rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 8px 18px rgba(27, 20, 9, 0.12);
    z-index: 4;
    top: 0.25rem;
    right: 0.25rem;
    overflow: hidden;
    transition: gap 0.2s ease, padding 0.2s ease, box-shadow 0.2s ease;
}

.workspace-toolbar.is-collapsed {
    gap: 0;
    padding: 0.2rem 0.25rem;
    box-shadow: 0 6px 14px rgba(27, 20, 9, 0.1);
}

.workspace-toolbar-btn {
    border: none;
    background: transparent;
    font-family: var(--body-font);
    font-size: 0.7rem;
    padding: 0;
    width: 34px;
    height: 30px;
    border-radius: 999px;
    cursor: pointer;
    color: var(--fg);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: opacity 0.2s ease, transform 0.2s ease, max-width 0.2s ease, padding 0.2s ease, width 0.2s ease;
}

.workspace-toolbar-btn.workspace-toolbar-toggle {
    font-weight: 600;
}

.workspace-toolbar.is-collapsed .workspace-toolbar-btn:not(.workspace-toolbar-toggle) {
    opacity: 0;
    transform: translateX(6px);
    max-width: 0;
    width: 0;
    padding: 0;
    pointer-events: none;
}

.workspace-toolbar-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.workspace-toolbar-btn::before {
    content: "";
    display: block;
}

.workspace-toolbar-btn[data-action="menu"]::before {
    width: 16px;
    height: 10px;
    background:
        linear-gradient(var(--fg) 0 0) 0 0 / 100% 2px no-repeat,
        linear-gradient(var(--fg) 0 0) 0 50% / 100% 2px no-repeat,
        linear-gradient(var(--fg) 0 0) 0 100% / 100% 2px no-repeat;
}

.workspace-toolbar-btn[data-action="h1"]::before {
    content: "H1";
    font-weight: 600;
    letter-spacing: -0.02em;
}

.workspace-toolbar-btn[data-action="h2"]::before {
    content: "H2";
    font-weight: 600;
    letter-spacing: -0.02em;
}

.workspace-toolbar-btn[data-action="bold"]::before {
    content: "B";
    font-weight: 700;
}

.workspace-toolbar-btn[data-action="italic"]::before {
    content: "I";
    font-style: italic;
}

.workspace-toolbar-btn[data-action="line"]::before {
    width: 16px;
    height: 2px;
    background: var(--fg);
    border-radius: 999px;
}

.workspace-toolbar-btn[data-action="keyboard"]::before {
    width: 16px;
    height: 12px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 16'%3E%3Crect x='1' y='1' width='22' height='14' rx='2' ry='2' fill='none' stroke='%23000' stroke-width='1.5'/%3E%3Crect x='4' y='5' width='2' height='2' fill='%23000'/%3E%3Crect x='8' y='5' width='2' height='2' fill='%23000'/%3E%3Crect x='12' y='5' width='2' height='2' fill='%23000'/%3E%3Crect x='16' y='5' width='2' height='2' fill='%23000'/%3E%3Crect x='6' y='9' width='12' height='2' fill='%23000'/%3E%3C/svg%3E");
}

.workspace-toolbar-btn[data-action="clear"]::before {
    width: 14px;
    height: 14px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M4 7h16M9 7V5h6v2M8 7l1 12h6l1-12'/%3E%3C/svg%3E");
}

.workspace-toolbar-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

.workspace-toolbar-btn.is-active {
    background: rgba(0, 0, 0, 0.12);
    font-weight: 700;
}

/* Result page workspace preview */
.result-workspace-preview {
    margin-bottom: 0.75rem;
    padding: 1rem;
    border-radius: 10px;
    background: #fdfbf7;
    border: 1px solid #e8e2d8;
}

.result-workspace-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-workspace-canvas {
    position: relative;
    min-height: 160px;
    border-radius: 10px;
    border: 1px solid #e8e2d8;
    background: #fffefb;
    overflow: hidden;
}

.result-workspace-block {
    position: absolute;
    max-width: 85%;
    padding: 0.1rem 0.2rem;
    background: transparent;
    border: none;
    border-radius: 0;
    font-size: 0.85rem;
    white-space: pre-wrap;
    z-index: 1;
}

.result-workspace-line {
    position: absolute;
    height: 2px;
    background: var(--fg);
    border-radius: 999px;
    transform-origin: 0 50%;
    opacity: 0.85;
    z-index: 0;
}

.result-workspace-block[data-style="h1"] {
    font-size: 1rem;
    font-weight: 600;
}

.result-workspace-block[data-style="h2"] {
    font-size: 0.95rem;
    font-weight: 600;
}

.result-workspace-block[data-bold="true"] {
    font-weight: 700;
}

.result-workspace-block[data-italic="true"] {
    font-style: italic;
}

.result-workspace-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.85rem;
}

.result-workspace-row {
    display: flex;
    gap: 2px;
}

.result-workspace-cell {
    min-width: 32px;
    padding: 4px 6px;
    background: #ffffff;
    border: 1px solid #ece6dc;
    border-radius: 4px;
    text-align: center;
}

.result-workspace-cell:empty {
    background: transparent;
    border-color: transparent;
}

/* Responsive adjustments for workspace */
@media (max-width: 768px) {
    .workspace-canvas {
        min-height: 220px;
    }

    .workspace-block {
        max-width: 94%;
        padding: 0.2rem 0.35rem;
    }

    .workspace-block-math {
        font-size: 1.1rem;
    }

    .result-workspace-canvas {
        min-height: 140px;
    }
}

/* ================================================
   AGENT MONITOR - Development Tool Styles
   ================================================ */

.agent-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
    color: #e8e8e8;
    overflow: hidden;
}

.agent-container {
    max-width: 100%;
    min-height: 100vh;
    padding: 0 2rem;
}

/* Header */
.agent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.agent-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.agent-header h1 {
    font-family: var(--header-font);
    font-size: 1.75rem;
    font-weight: 400;
    color: #ffffff;
    letter-spacing: -0.02em;
}

.agent-header-badge {
    padding: 0.25rem 0.6rem;
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    border-radius: 4px;
    text-transform: uppercase;
}

.agent-header-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.agent-poll-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

.poll-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    animation: pollPulse 1.5s ease-in-out infinite;
}

.agent-poll-indicator.paused .poll-dot {
    background: #fbbf24;
    animation: none;
}

.agent-poll-indicator.paused .poll-text::after {
    content: ' (pausad)';
}

@keyframes pollPulse {
    0%, 100% { opacity: 0.4; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
}

.btn-agent {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-agent:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Viewport */
.agent-viewport {
    position: relative;
    min-height: calc(100vh - 100px);
    padding: 2rem 0;
}

.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 1.5rem;
    transition: transform 0.3s ease;
}

/* Empty State */
.agent-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    color: rgba(255, 255, 255, 0.4);
}

.empty-icon {
    margin-bottom: 1.5rem;
    opacity: 0.3;
}

.empty-icon svg {
    stroke: rgba(255, 255, 255, 0.5);
}

.agent-empty-state h3 {
    font-family: var(--header-font);
    font-size: 1.5rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.5rem;
}

.agent-empty-state p {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.4);
}

/* Agent Card */
.agent-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.agent-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
}

.agent-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.25rem 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.agent-card-info {
    flex: 1;
    min-width: 0;
}

.agent-card-title {
    font-family: var(--header-font);
    font-size: 1.15rem;
    font-weight: 400;
    color: #ffffff;
    margin-bottom: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.meta-separator {
    opacity: 0.3;
}

.meta-type {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
}

/* Status Badge */
.agent-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    background: var(--status-bg);
    color: var(--status-fg);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.status-pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: statusPulse 1.2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 0.5; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Iterations Container */
.agent-iterations {
    padding: 1rem 1.25rem;
    max-height: 450px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.agent-iterations::-webkit-scrollbar {
    width: 6px;
}

.agent-iterations::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

.agent-iterations::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.agent-iterations::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Iteration Block */
.iteration-block {
    padding: 0.9rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.iteration-block.current {
    background: rgba(74, 222, 128, 0.05);
    border-color: rgba(74, 222, 128, 0.2);
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.1);
}

.iteration-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}

.iteration-step {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.progress-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    animation: progressPulse 1s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { opacity: 0.4; transform: scale(0.8); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.4); }
    50% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
}

/* Tool Blocks Container */
.iteration-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Tool Block */
.tool-block {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    background: var(--tool-bg, rgba(255, 255, 255, 0.1));
    color: var(--tool-fg, #ffffff);
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.tool-block:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

.tool-icon {
    font-size: 0.85rem;
}

.tool-name {
    text-transform: capitalize;
}

.tool-result-indicator {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    margin-left: 0.2rem;
}

.tool-result-indicator.success {
    background: #4ade80;
}

.tool-result-indicator.failed {
    background: #f87171;
}

/* Tool Popup */
.tool-popup {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: #1e1e2e;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
    pointer-events: none;
}

.tool-popup::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #1e1e2e;
}

.tool-block:hover .tool-popup {
    opacity: 1;
    visibility: visible;
}

.popup-section {
    margin-bottom: 0.85rem;
}

.popup-section:last-child {
    margin-bottom: 0;
}

.popup-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 0.4rem;
}

.popup-content {
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    word-break: break-word;
}

.popup-reasoning {
    color: #a78bfa;
    font-style: italic;
    font-family: var(--body-font);
}

.popup-args {
    color: #60a5fa;
}

.popup-result {
    color: #4ade80;
}

/* Context Block */
.context-block {
    padding: 0.5rem 0.75rem;
    background: rgba(96, 165, 250, 0.1);
    border: 1px solid rgba(96, 165, 250, 0.2);
    border-radius: 6px;
    font-size: 0.78rem;
    color: #60a5fa;
}

/* Error Block */
.error-block {
    padding: 0.5rem 0.75rem;
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: 6px;
    font-size: 0.78rem;
    color: #f87171;
}

/* Zoom Controls */
.zoom-controls {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    gap: 0.5rem;
    z-index: 50;
}

.zoom-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.zoom-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.zoom-btn-text {
    width: auto;
    padding: 0 0.75rem;
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 900px) {
    .agent-grid {
        grid-template-columns: 1fr;
    }

    .agent-container {
        padding: 0 1rem;
    }

    .zoom-controls {
        bottom: 1rem;
        right: 1rem;
    }
}

@media (max-width: 500px) {
    .agent-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .agent-header-right {
        width: 100%;
        justify-content: space-between;
    }

    .tool-popup {
        width: 280px;
        left: 0;
        transform: none;
    }

    .tool-popup::after {
        left: 20px;
        transform: none;
    }
}
