/**
 * Practice Interface Styles
 * Specific styles for the exam practice mode
 */

/* ============================================
   PRACTICE LAYOUT
   ============================================ */
.practice-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-secondary);
}

.practice-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    z-index: 100;
}

.practice-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.practice-header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.practice-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.practice-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    display: none;
}

@media (min-width: 640px) {
    .practice-title {
        display: block;
    }
}

/* Timer */
.practice-timer {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.practice-timer svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.practice-timer.warning {
    background: var(--warning-light);
    color: var(--warning);
}

.practice-timer.danger {
    background: var(--error-light);
    color: var(--error);
    animation: pulse 1s infinite;
}

/* ============================================
   PRACTICE MAIN AREA
   ============================================ */
.practice-main {
    display: flex;
    flex: 1;
    padding-top: var(--header-height);
}

/* Navigator Panel (Desktop) */
.practice-navigator {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: 200px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    padding: var(--space-4);
    overflow-y: auto;
}

@media (min-width: 992px) {
    .practice-navigator {
        display: block;
    }
}

.navigator-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: var(--space-4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.navigator-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-2);
}

.navigator-item {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 500;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
}

.navigator-item:hover {
    background: var(--accent-light);
    border-color: var(--accent-primary);
}

.navigator-item.current {
    background: var(--accent-primary);
    color: var(--text-inverse);
    border-color: var(--accent-primary);
}

.navigator-item.answered {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success-dark);
}

.navigator-item.marked {
    background: var(--warning-light);
    border-color: var(--warning);
    color: var(--warning);
}

.navigator-item.answered.marked {
    background: var(--success-light);
    border-color: var(--warning);
}

.navigator-legend {
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-sm);
    border: 2px solid;
}

.legend-dot.current {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.legend-dot.answered {
    background: var(--success-light);
    border-color: var(--success);
}

.legend-dot.marked {
    background: var(--warning-light);
    border-color: var(--warning);
}

.legend-dot.unanswered {
    background: var(--bg-tertiary);
    border-color: var(--border);
}

/* ============================================
   QUESTION AREA
   ============================================ */
.practice-content {
    flex: 1;
    padding: var(--space-4);
    max-width: 100%;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .practice-content {
        padding: var(--space-6);
    }
}

@media (min-width: 992px) {
    .practice-content {
        margin-left: 200px;
        margin-right: 260px;
        padding: var(--space-8);
    }
}

.question-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-4);
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.question-number {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.question-meta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.question-marks {
    font-size: var(--text-sm);
    color: var(--text-muted);
    padding: var(--space-1) var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

.question-type {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.question-content {
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    color: var(--text-primary);
    margin-bottom: var(--space-6);
}

.question-content p {
    margin-bottom: var(--space-4);
}

/* Math rendering */
.question-content .math-inline {
    font-family: var(--font-mono);
}

/* SVG Diagrams */
.question-diagram {
    margin: var(--space-6) 0;
    text-align: center;
}

.question-diagram svg {
    max-width: 100%;
    height: auto;
    max-height: 300px;
}

/* ============================================
   MCQ OPTIONS
   ============================================ */
.options-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.option-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.option-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.option-item.selected {
    background: var(--accent-light);
    border-color: var(--accent-primary);
}

.option-item.correct {
    background: var(--success-light);
    border-color: var(--success);
}

.option-item.incorrect {
    background: var(--error-light);
    border-color: var(--error);
}

.option-item.disabled {
    pointer-events: none;
    opacity: 0.7;
}

.option-radio {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.option-item.selected .option-radio {
    border-color: var(--accent-primary);
    background: var(--accent-primary);
}

.option-item.selected .option-radio::after {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

.option-item.correct .option-radio {
    border-color: var(--success);
    background: var(--success);
}

.option-item.correct .option-radio::after {
    content: '';
    width: 10px;
    height: 10px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E") center/contain no-repeat;
}

.option-item.incorrect .option-radio {
    border-color: var(--error);
    background: var(--error);
}

.option-item.incorrect .option-radio::after {
    content: '';
    width: 10px;
    height: 10px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E") center/contain no-repeat;
}

.option-label {
    font-weight: 600;
    color: var(--text-muted);
    min-width: 24px;
}

.option-text {
    flex: 1;
    color: var(--text-primary);
}

.option-result {
    font-size: var(--text-xs);
    font-weight: 500;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
}

.option-result.correct-answer {
    background: var(--success-light);
    color: var(--success-dark);
}

.option-result.your-answer {
    background: var(--error-light);
    color: var(--error);
}

/* ============================================
   SUBJECTIVE ANSWER INPUT
   ============================================ */
.answer-input {
    width: 100%;
    padding: var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    resize: vertical;
    min-height: 100px;
    transition: border-color var(--transition-fast);
}

.answer-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

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

/* ============================================
   MATH INPUT - STUDENT FRIENDLY
   ============================================ */
.math-input-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* Quick Math Insert Bar */
.quick-math-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.quick-math-label {
    font-size: var(--text-sm);
    color: var(--text-muted);
    white-space: nowrap;
}

.quick-math-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

.quick-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 var(--space-2);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--text-base);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.quick-btn:active {
    transform: translateY(0);
}

/* Input Hint */
.input-hint {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.input-hint svg {
    flex-shrink: 0;
    color: var(--accent-primary);
}

.input-hint code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    color: var(--accent-primary);
}

/* Math Preview */
.math-preview-container {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
}

.math-preview-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
}

.math-preview-label svg {
    color: var(--success);
}

.math-preview {
    min-height: 32px;
    font-size: var(--text-lg);
    line-height: 1.8;
    color: var(--text-primary);
    word-wrap: break-word;
}

/* Responsive */
@media (max-width: 640px) {
    .quick-math-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .quick-btn {
        min-width: 32px;
        height: 32px;
        font-size: var(--text-sm);
    }

    .input-hint {
        flex-wrap: wrap;
    }

    .input-hint span {
        flex: 1 1 100%;
        margin-top: var(--space-1);
    }
}

/* ============================================
   CASE STUDY
   ============================================ */
.case-study-box {
    background: var(--bg-tertiary);
    border-left: 4px solid var(--accent-primary);
    border-radius: var(--radius-md);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
}

.case-study-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: var(--space-4);
}

.case-study-content {
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

.sub-question {
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border);
}

.sub-question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.sub-question-number {
    font-weight: 600;
    color: var(--text-primary);
}

.sub-question-marks {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* ============================================
   SOLUTION BOX
   ============================================ */
.solution-box {
    background: var(--success-light);
    border: 1px solid var(--success);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-top: var(--space-6);
}

[data-theme="dark"] .solution-box {
    background: rgba(16, 185, 129, 0.1);
}

.solution-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--success-dark);
    margin-bottom: var(--space-4);
}

.solution-header svg {
    width: 24px;
    height: 24px;
}

.solution-steps {
    list-style: none;
    counter-reset: step;
}

.solution-step {
    position: relative;
    padding-left: var(--space-8);
    margin-bottom: var(--space-3);
    color: var(--text-secondary);
}

.solution-step::before {
    counter-increment: step;
    content: counter(step);
    position: absolute;
    left: 0;
    width: 24px;
    height: 24px;
    background: var(--success);
    color: white;
    border-radius: 50%;
    font-size: var(--text-xs);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.solution-answer {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid rgba(16, 185, 129, 0.3);
    font-weight: 600;
    color: var(--success-dark);
}

/* ============================================
   QUESTION ACTIONS
   ============================================ */
.question-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

.question-actions-left {
    display: flex;
    gap: var(--space-3);
}

.question-actions-right {
    display: flex;
    gap: var(--space-3);
    margin-left: auto;
}

/* ============================================
   PROGRESS PANEL (Desktop Right Sidebar)
   ============================================ */
.practice-progress {
    display: none;
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: 260px;
    background: var(--bg-primary);
    border-left: 1px solid var(--border);
    padding: var(--space-6);
    overflow-y: auto;
}

@media (min-width: 992px) {
    .practice-progress {
        display: block;
    }
}

.progress-section {
    margin-bottom: var(--space-6);
}

.progress-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: var(--space-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.progress-stat {
    text-align: center;
    padding: var(--space-4);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.progress-stat-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--accent-primary);
}

.progress-stat-label {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.progress-bar-container {
    margin-top: var(--space-4);
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.progress-breakdown {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

.progress-breakdown-item {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.progress-breakdown-value {
    font-weight: 600;
}

/* ============================================
   MOBILE NAVIGATOR (Bottom Sheet)
   ============================================ */
.mobile-navigator {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-xl);
    transform: translateY(100%);
    transition: transform var(--transition-normal);
    z-index: 110;
    max-height: 70vh;
    overflow: hidden;
}

.mobile-navigator.open {
    transform: translateY(0);
}

@media (min-width: 992px) {
    .mobile-navigator {
        display: none;
    }
}

.mobile-navigator-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.mobile-navigator-title {
    font-weight: 600;
    color: var(--text-primary);
}

.mobile-navigator-body {
    padding: var(--space-4);
    overflow-y: auto;
    max-height: calc(70vh - 60px);
}

.mobile-navigator-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--space-2);
}

.mobile-navigator-footer {
    padding: var(--space-4);
    border-top: 1px solid var(--border);
}

/* Mobile Navigator Toggle Button */
.mobile-nav-toggle {
    position: fixed;
    bottom: var(--space-4);
    right: var(--space-4);
    width: 56px;
    height: 56px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
}

.mobile-nav-toggle svg {
    width: 24px;
    height: 24px;
}

@media (min-width: 992px) {
    .mobile-nav-toggle {
        display: none;
    }
}

/* Mobile Submit Button */
.mobile-submit-btn {
    position: fixed;
    bottom: var(--space-4);
    left: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 100;
    transition: background 0.2s, transform 0.2s;
}

.mobile-submit-btn:hover {
    background: var(--success-dark);
    transform: scale(1.02);
}

.mobile-submit-btn:active {
    transform: scale(0.98);
}

.mobile-submit-btn svg {
    width: 18px;
    height: 18px;
}

@media (min-width: 992px) {
    .mobile-submit-btn {
        display: none;
    }
}

/* ============================================
   RESULTS PAGE
   ============================================ */
.results-container {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-4);
}

.results-header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.results-title {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

.results-score-circle {
    width: 160px;
    height: 160px;
    margin: 0 auto var(--space-6);
    background: var(--bg-hero);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.results-score-value {
    font-size: var(--text-4xl);
    font-weight: 700;
}

.results-score-label {
    font-size: var(--text-sm);
    opacity: 0.9;
}

.results-breakdown {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
}

.results-breakdown-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

.results-breakdown-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    text-align: center;
}

.results-breakdown-item {
    padding: var(--space-4);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.results-breakdown-value {
    font-size: var(--text-2xl);
    font-weight: 700;
}

.results-breakdown-value.correct {
    color: var(--success);
}

.results-breakdown-value.incorrect {
    color: var(--error);
}

.results-breakdown-value.unattempted {
    color: var(--text-muted);
}

.results-breakdown-label {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

@media (min-width: 480px) {
    .results-actions {
        flex-direction: row;
        justify-content: center;
    }
}

/* ============================================
   LOADING STATE
   ============================================ */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

[data-theme="dark"] .loading-overlay {
    background: rgba(15, 23, 42, 0.9);
}

/* ===== Quick Math inside the Math Studio shell =====
   Neutralizes the few exams.css layout helpers the pages used so the tool
   renders single-column inside .ms-workspace (the studio ms-rail + ms-crumbs
   replace the old ad columns and breadcrumb). Lets us drop exams/css entirely. */
.ms-workspace .container { max-width: 100%; margin: 0; padding: 0; }
.ms-workspace .container.main-content { padding: 0; }
.ms-workspace .grid.layout-grid { display: block; }
.ms-workspace .left-sidebar-col,
.ms-workspace .right-sidebar-col { display: none; }
.ms-workspace .breadcrumb { display: none; }

/* ===== Studio fit: right-size the Quick Math tool inside .ms-workspace =====
   The tool was built for the full-width exams hub; these scoped overrides
   (higher specificity than the page's inline <style>) tame it for the
   narrower studio workspace and remove the heading duplicated by ms-title. */

/* Constrain line length for readability */
.ms-workspace .practice-col { max-width: 780px; margin: 0 auto; }

/* The studio ms-title already shows the page H1 + breadcrumbs */
.ms-workspace #topic-title { display: none; }
.ms-workspace .card > header { margin-bottom: 0.75rem; }

/* Chalkboard / step visualizer */
.ms-workspace .visualizer-box { padding: 1.1rem 1.25rem; }
.ms-workspace .visualizer-box .math-visualizer { font-size: 1rem; }
.ms-workspace .visualizer-box .step-intro { font-size: 1.15rem !important; line-height: 1.45; }
.ms-workspace .visualizer-box .problem { font-size: 1.25rem; }
.ms-workspace .visualizer-box .step { font-size: 0.98rem; }
.ms-workspace .visualizer-box .result { font-size: 1.2rem; }

/* Game card: question + stats + input */
.ms-workspace .question-display { font-size: clamp(1.3rem, 2.2vw, 1.8rem); margin: 1rem 0; line-height: 1.35; }
.ms-workspace .stat-value { font-size: 1.45rem; }
.ms-workspace .game-input { font-size: 1.4rem; }
.ms-workspace .game-header { gap: 1rem; }

/* Section/learn headings */
.ms-workspace .learn-section h3 { font-size: 1.05rem; }

/* ===== Theme alias: make the tool follow the math-studio palette =====
   The tool references design-system tokens (--bg-*, --text-*, --accent-*)
   which track prefers-color-scheme and drift dark against the studio's
   [data-theme] chrome. Re-point them at the --ms-* tokens (which flip with
   the studio theme) so the cards/stats match the workspace in both modes. */
.ms-workspace {
    --bg-primary:     var(--ms-panel-bg);
    --bg-secondary:   var(--ms-panel-bg-soft);
    --bg-tertiary:    var(--ms-panel-bg-soft);
    --bg-hover:       var(--ms-panel-bg-soft);
    --text-primary:   var(--ms-ink);
    --text-secondary: var(--ms-ink-soft);
    --text-muted:     var(--ms-muted);
    --border:         var(--ms-line);
    --border-dark:    var(--ms-line-strong);
    --accent-primary: var(--ms-accent);
    --accent-dark:    var(--ms-accent-hover);
    --accent-light:   var(--ms-accent-soft);
}

/* ===== Collapsible "How it works" (worked example), secondary to the drill ===== */
.ms-workspace .learn-details > summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ms-ink);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.ms-workspace .learn-details > summary::-webkit-details-marker { display: none; }
.ms-workspace .learn-details > summary::before {
    content: '▸';
    color: var(--ms-accent);
    transition: transform 0.18s var(--ms-ease, ease);
}
.ms-workspace .learn-details[open] > summary::before { transform: rotate(90deg); }
.ms-workspace .learn-details[open] > summary { margin-bottom: 0.85rem; }

/* ===== Best-streak/accuracy stats + share-to-social ===== */
.ms-workspace .game-header { flex-wrap: wrap; row-gap: 0.75rem; }
.ms-workspace .game-header .stat-box { flex: 1 1 auto; min-width: 68px; }

.ms-workspace .game-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.ms-workspace .share-menu { display: flex; flex-wrap: wrap; gap: 0.4rem; width: 100%; margin-top: 0.4rem; }
.ms-workspace .share-menu[hidden] { display: none; }
.ms-workspace .share-chip {
    font-size: 0.8rem; font-weight: 600; padding: 0.32rem 0.7rem; border-radius: 999px;
    border: 1px solid var(--ms-line-strong); background: var(--ms-panel-bg-soft);
    color: var(--ms-ink); text-decoration: none; cursor: pointer; line-height: 1.2;
}
.ms-workspace .share-chip:hover { border-color: var(--ms-accent); color: var(--ms-accent); }

/* ===== Button system (exams.css was dropped — define them in the studio palette) ===== */
.ms-workspace .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.6rem 1.15rem; border-radius: var(--ms-radius-pill, 999px);
    font-family: var(--ms-font-sans, 'Inter', sans-serif); font-weight: 600; font-size: 0.92rem; line-height: 1;
    border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
    -webkit-appearance: none; appearance: none;
    transition: transform .15s var(--ms-ease, ease), box-shadow .15s, background .15s, border-color .15s, color .15s, filter .15s;
}
.ms-workspace .btn:focus-visible { outline: none; box-shadow: var(--ms-ring, 0 0 0 3px rgba(21,128,61,.3)); }
.ms-workspace .btn:active { transform: translateY(1px); }
.ms-workspace .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; filter: none; }

.ms-workspace .btn-primary {
    background: linear-gradient(135deg, var(--ms-cta-start, #15803d), var(--ms-cta-end, #22c55e));
    color: #fff; box-shadow: 0 2px 8px var(--ms-cta-shadow, rgba(21,128,61,.22));
}
.ms-workspace .btn-primary:hover:not(:disabled) {
    filter: brightness(1.05); transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--ms-cta-shadow, rgba(21,128,61,.32));
}
.ms-workspace .btn-secondary {
    background: var(--ms-panel-bg, #fff); color: var(--ms-ink-soft, #44403c);
    border-color: var(--ms-line-strong, rgba(28,25,23,.14));
}
.ms-workspace .btn-secondary:hover:not(:disabled) {
    border-color: var(--ms-accent, #15803d); color: var(--ms-accent, #15803d);
    background: var(--ms-accent-softer, rgba(21,128,61,.04)); transform: translateY(-1px);
}
.ms-workspace .btn-sm { padding: 0.42rem 0.85rem; font-size: 0.82rem; }
.ms-workspace .btn-game { padding: 0.72rem 1.7rem; font-size: 1.02rem; border-radius: var(--ms-radius, 14px); }

/* Answer field to match */
.ms-workspace .input-group { gap: 0.5rem; max-width: 440px; }
.ms-workspace .game-input {
    border: 2px solid var(--ms-line-strong, rgba(28,25,23,.14)); border-radius: var(--ms-radius, 14px);
    background: var(--ms-panel-bg, #fff); color: var(--ms-ink, #1c1917); font-weight: 700;
    transition: border-color .15s, box-shadow .15s;
}
.ms-workspace .game-input:focus { border-color: var(--ms-accent, #15803d); box-shadow: var(--ms-ring, 0 0 0 3px rgba(21,128,61,.22)); outline: none; }
