/* ==========================================================================
   M1 Adaptive Prep & Quiz Engine Styles
   ========================================================================== */

.m1-app-container {
    font-family: 'Prompt', 'Sarabun', system-ui, -apple-system, sans-serif;
    max-width: 920px;
    margin: 2rem auto;
    background: #ffffff;
    border-radius: 1.25rem;
    box-shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.08), 0 0 1px 1px rgba(15, 23, 42, 0.05);
    overflow: hidden;
    color: #1e293b;
    border: 1px solid #e2e8f0;
}

/* Header */
.m1-quiz-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #312e81 100%);
    color: #ffffff;
    padding: 1.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.m1-header-title-area {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.m1-badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    border-radius: 9999px;
    text-transform: uppercase;
    width: fit-content;
}

.m1-badge-primary {
    background: rgba(255, 255, 255, 0.18);
    color: #e0e7ff;
    backdrop-filter: blur(4px);
}

.m1-badge-sm {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    background: #e2e8f0;
    color: #475569;
}

.m1-quiz-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
    color: #ffffff;
}

.m1-header-status-area {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.m1-timer-box {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(0, 0, 0, 0.25);
    padding: 0.5rem 0.9rem;
    border-radius: 0.5rem;
    font-family: 'Courier New', monospace;
    font-weight: 700;
    font-size: 1.15rem;
    color: #fef08a;
    border: 1px solid rgba(254, 240, 138, 0.25);
}

.m1-difficulty-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #cbd5e1;
}

.m1-diff-dots {
    display: flex;
    gap: 0.3rem;
}

.m1-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    transition: all 0.3s ease;
}

.m1-dot.active {
    background: #38bdf8;
    box-shadow: 0 0 8px #38bdf8;
    transform: scale(1.25);
}

/* Screens */
.m1-screen {
    padding: 2rem;
    transition: opacity 0.3s ease;
}

.m1-hidden {
    display: none !important;
}

/* Welcome Card */
.m1-welcome-card {
    text-align: center;
    padding: 3rem 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.m1-welcome-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

.m1-welcome-card h3 {
    font-size: 1.65rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.75rem;
}

.m1-welcome-desc {
    color: #64748b;
    font-size: 1.05rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

/* Progress */
.m1-progress-wrap {
    margin-bottom: 1.5rem;
}

.m1-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    color: #475569;
    font-weight: 500;
}

.m1-topic-badge {
    background: #f1f5f9;
    color: #1e40af;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.8rem;
    border: 1px solid #e2e8f0;
}

.m1-progress-bar-bg {
    height: 0.5rem;
    background: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
}

.m1-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #6366f1);
    transition: width 0.4s ease;
}

/* Mock Nav Grid */
.m1-mock-nav-wrap {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.m1-mock-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.75rem;
}

.m1-flag-btn {
    background: none;
    border: 1px solid #cbd5e1;
    padding: 0.25rem 0.65rem;
    border-radius: 0.35rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: #475569;
    transition: all 0.2s;
}

.m1-flag-btn.flagged {
    background: #fef2f2;
    border-color: #f87171;
    color: #dc2626;
    font-weight: bold;
}

.m1-mock-nav-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.m1-mock-q-btn {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 0.4rem;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    color: #475569;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.m1-mock-q-btn.current {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
    box-shadow: 0 0 0 2px #93c5fd;
}

.m1-mock-q-btn.answered {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}

.m1-mock-q-btn.flagged::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    background: #ef4444;
    border-radius: 50%;
}

/* Question Content */
.m1-question-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.m1-q-text {
    font-size: 1.25rem;
    line-height: 1.7;
    color: #1e293b;
    margin-bottom: 2rem;
    font-weight: 500;
}

.m1-options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
    margin-bottom: 2rem;
}

@media (min-width: 640px) {
    .m1-options-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.m1-option-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    cursor: pointer;
    background: #f8fafc;
    transition: all 0.2s ease;
}

.m1-option-item:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    transform: translateY(-2px);
}

.m1-option-item.selected {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 0 0 1px #2563eb;
}

.m1-option-badge {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #e2e8f0;
    color: #334155;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    transition: all 0.2s;
}

.m1-option-item.selected .m1-option-badge {
    background: #2563eb;
    color: #ffffff;
}

.m1-option-text {
    font-size: 1.05rem;
    color: #1e293b;
    font-weight: 500;
}

/* Feedback Box */
.m1-feedback-box {
    padding: 1.25rem;
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.6;
    animation: m1FadeIn 0.3s ease;
}

.m1-feedback-box.correct {
    background: #ecfdf5;
    border: 1px solid #6ee7b7;
    color: #065f46;
}

.m1-feedback-box.incorrect {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.m1-fb-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
}

/* Footer / Actions */
.m1-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1.25rem;
    border-top: 1px solid #f1f5f9;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.m1-footer-right {
    display: flex;
    gap: 0.5rem;
}

.m1-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.35rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.m1-btn-primary {
    background: #2563eb;
    color: #ffffff;
}

.m1-btn-primary:hover:not(:disabled) {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.m1-btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    opacity: 0.7;
}

.m1-btn-secondary {
    background: #7c3aed;
    color: #ffffff;
}

.m1-btn-secondary:hover {
    background: #6d28d9;
}

.m1-btn-success {
    background: #059669;
    color: #ffffff;
}

.m1-btn-success:hover {
    background: #047857;
}

.m1-btn-outline {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
}

.m1-btn-outline:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.m1-btn-subtle {
    background: #f1f5f9;
    color: #475569;
}

.m1-btn-subtle:hover {
    background: #e2e8f0;
}

.m1-btn-lg {
    padding: 0.85rem 2rem;
    font-size: 1.1rem;
    border-radius: 0.65rem;
}

.m1-btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
}

.m1-btn-block {
    width: 100%;
}

/* Result Card */
.m1-result-card {
    text-align: center;
    padding: 2.5rem 2rem;
}

.m1-result-badge-top {
    font-size: 0.85rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.m1-score-circle {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.m1-score-num {
    font-size: 4rem;
    font-weight: 800;
    color: #1e3a8a;
    line-height: 1;
}

.m1-score-total {
    font-size: 1.75rem;
    color: #64748b;
    font-weight: 600;
}

.m1-score-percent {
    font-size: 1.5rem;
    font-weight: 700;
    color: #059669;
    margin-bottom: 1.5rem;
}

.m1-chance-box {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    margin-bottom: 2rem;
    font-weight: 600;
}

.m1-chance-val {
    font-weight: 700;
    margin-left: 0.5rem;
}

.m1-domain-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2.5rem;
    text-align: left;
}

.m1-domain-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    padding: 1rem;
}

.m1-ditem-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.5rem;
}

.m1-ditem-bar-bg {
    height: 0.4rem;
    background: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 0.35rem;
}

.m1-ditem-bar-fill {
    height: 100%;
    background: #3b82f6;
}

.m1-ditem-sub {
    font-size: 0.75rem;
    color: #64748b;
}

.m1-result-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.m1-review-list {
    margin-top: 2rem;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.m1-review-item {
    padding: 1.25rem;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
    background: #ffffff;
}

.m1-review-item.is-correct {
    border-left: 4px solid #10b981;
}

.m1-review-item.is-wrong {
    border-left: 4px solid #ef4444;
}

.m1-ritem-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.m1-ritem-answer {
    margin-top: 0.5rem;
    font-size: 0.95rem;
}

.m1-ritem-solution {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #e2e8f0;
    color: #047857;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Review answers: option letter + option text, same as the question screen. */
.m1-ritem-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.5rem;
    margin-top: 0.3rem;
}

.m1-ritem-key {
    min-width: 7.5rem;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 600;
}

.m1-ritem-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6rem;
    height: 1.6rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #334155;
    font-size: 0.85rem;
    font-weight: 700;
}

.m1-ritem-text {
    flex: 1 1 12rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.m1-ritem-line.is-correct .m1-ritem-badge,
.m1-ritem-line.is-key .m1-ritem-badge {
    background: #d1fae5;
    color: #047857;
}

.m1-ritem-line.is-key .m1-ritem-text {
    color: #047857;
    font-weight: 600;
}

.m1-ritem-line.is-wrong .m1-ritem-badge {
    background: #fee2e2;
    color: #b91c1c;
}

.m1-ritem-text--none {
    color: #94a3b8;
}

@keyframes m1FadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Size of the approved pool this Mock draws from (start screen). */
.m1-pool-count {
    margin: -1rem auto 1.5rem;
    max-width: 36rem;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    background: #f6f1ee;
    color: #3f3437;
    font-size: 0.98rem;
    line-height: 1.6;
}

.m1-pool-count strong {
    color: #7c2137;
}

.m1-pool-count--short {
    background: #fff4e5;
    color: #6b3d00;
}

.m4ac-question-table {
    border-collapse: collapse;
    max-width: 100%;
    margin: 1rem 0;
    font-variant-numeric: tabular-nums;
}
.m4ac-question-table caption {
    text-align: start;
    font-weight: 600;
    padding-bottom: .4rem;
}
.m4ac-question-table th, .m4ac-question-table td {
    border: 1px solid #c8b7bb;
    padding: .4rem .8rem;
    text-align: start;
}
.m4ac-question-table thead th { background: #f6f1ee; }
.m4ac-question-table td { text-align: end; }

.m4ac-worked-steps { margin: .5rem 0 1rem; padding-inline-start: 1.65rem; }
.m4ac-worked-steps li { margin-block: .35rem; }
.m4ac-solution-figure { margin: 1rem 0; max-width: 32rem; }
.m4ac-solution-figure figcaption { margin-top: .6rem; font-size: .93em; }
.m4ac-rectangle-sketch {
    position: relative; margin: .7rem 0 2.4rem 3.4rem; width: min(15rem, 65%); aspect-ratio: 15 / 8;
    border: 2px solid #334b60;
    background: linear-gradient(to top right, transparent calc(50% - 1px), #176a73 calc(50% - 1px), #176a73 calc(50% + 1px), transparent calc(50% + 1px));
}
.m4ac-rectangle-sketch::before, .m4ac-rectangle-sketch::after, .m4ac-rectangle-sketch span {
    position: absolute; font-size: .9rem; white-space: nowrap;
}
.m4ac-rectangle-sketch::before { content: '8 ซม.'; right: calc(100% + .4rem); top: 40%; }
.m4ac-rectangle-sketch::after { content: '15 ซม.'; top: calc(100% + .2rem); left: 37%; }
.m4ac-rectangle-sketch span { left: 40%; top: 29%; background: white; color: #07575d; }
.m4ac-float-sketch { width: 7.5rem; border: 2px solid #334b60; text-align: center; font-variant-numeric: tabular-nums; }
.m4ac-float-sketch span { display: grid; place-items: center; box-sizing: border-box; color: #18394c; }
.m4ac-float-sketch span:first-child { height: 1.75rem; background: #fbf4df; }
.m4ac-float-sketch span:last-child { height: 7rem; background: #b5e2ee; border-top: 2px solid #196f89; }
