/* Shared compact treatment for navigation and action links. */
.main-content > form.question-bank-filters {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 10px;
    padding: 14px;
    max-width: none;
}
.question-bank-filters .bank-filter {
    flex: 1 1 120px;
    min-width: 0;
}
.question-bank-filters label {
    display: block;
    font-size: 11px;
    margin-bottom: 5px;
}
.question-bank-filters input:not([type='checkbox']),
.question-bank-filters select {
    width: 100%;
    min-width: 0;
    height: 36px;
    padding: 6px 9px;
    font-size: 12px;
}
.question-bank-filters .bank-filter-checkbox {
    flex: 0 0 auto;
}
.question-bank-filters .bank-filter-checkbox label {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    margin: 0;
    white-space: nowrap;
}
.question-bank-filters > a { flex-shrink: 0; }
@media (max-width: 1000px) {
    .main-content > form.question-bank-filters { flex-wrap: wrap; }
    .question-bank-filters .bank-filter { flex-basis: 140px; }
}
.workspace a:where(:not(.btn, .brand, .active-exam-link)),
a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    max-width: 100%;
    min-height: 32px;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    white-space: normal;
    overflow-wrap: anywhere;
    transition: background-color .15s, border-color .15s, color .15s;
}

.workspace a:where(:not(.btn, .brand, .active-exam-link)) {
    border: 1px solid #c4ddd4;
    background: #edf6f1;
    color: var(--teal-dark);
}

.workspace a:where(:not(.btn, .brand, .active-exam-link)):hover {
    border-color: #8fbab1;
    background: var(--mint);
    color: var(--teal-dark);
    text-decoration: none;
}

.workspace a:where(:not(.btn, .brand, .active-exam-link)):active {
    background: #cdebdc;
}

.workspace a + a {
    margin-inline-start: 4px;
}

.subject-card > a {
    align-self: flex-start;
}

.subject-card-header,
.subject-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.subject-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 20px;
    padding: 5px 10px;
    background: #f0f3f2;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.subject-status-active {
    background: var(--mint);
    color: var(--teal-dark);
}

.subject-status-icon {
    flex-shrink: 0;
    color: #b54708;
}

.subject-status-active .subject-status-icon {
    color: #16803c;
}

.subject-card-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
    padding-top: 8px;
    width: 100%;
}

.subject-action-row {
    align-items: stretch;
    flex-wrap: nowrap;
    width: 100%;
}

.subject-action-row-footer {
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.workspace .subject-action-row a {
    min-width: 0;
    padding: 6px;
    font-size: 11px;
    margin-inline-start: 0;
}

.subject-action-icon {
    flex-shrink: 0;
}

.quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-links a + a,
.handbook-toc a + a {
    margin-inline-start: 0;
}

.handbook-toc a {
    justify-content: flex-start;
    margin-block: 3px;
    text-align: start;
}

.table a.btn {
    white-space: normal;
}

.table td a {
    margin-block: 3px;
}

.active-exam-link {
    max-width: calc(100% - 32px);
    padding: 8px 12px;
    border: 1px solid #8fbab1;
    border-radius: 8px;
    font-size: 12px;
}

.pagination-bar {
    flex-wrap: wrap;
    gap: 8px;
}

@media (pointer: coarse) {
    .workspace a:where(:not(.brand)),
    .active-exam-link {
        min-height: 40px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .workspace a {
        transition: none;
    }
}

/* Assignment workspace and compact account actions. */
.main-content > form.assignment-form { padding: 0; background: transparent; border: 0; box-shadow: none; max-width: none; }
.assignment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.assignment-panel { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 24px; min-width: 0; }
.assignment-panel .section-heading { margin-top: 0; }
.assignment-panel h2 { font-size: 20px; }
.choice-count { color: var(--teal); background: var(--mint); padding: 5px 10px; border-radius: 20px; font-size: 11px; white-space: nowrap; }
.assignment-options { max-height: 380px; overflow-y: auto; margin-top: 18px; display: grid; gap: 8px; }
.assignment-option { display: flex; gap: 12px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; margin: 0; }
.assignment-option[hidden] { display: none; }
.assignment-option:has(input:checked) { background: #edf8f2; border-color: var(--teal); }
.assignment-option:focus-within { outline: 2px solid var(--teal); outline-offset: 2px; }
.assignment-option input { flex-shrink: 0; width: 18px; height: 18px; accent-color: var(--teal); }
.assignment-option span { overflow-wrap: anywhere; }
.assignment-summary { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 24px; padding: 24px; background: var(--mint); border-radius: 18px; }
.assignment-summary p { margin: 6px 0; }
.assignment-summary small { color: var(--muted); }
.assignment-submit, .user-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.user-actions { min-width: 220px; }
.user-actions form { margin: 0; }
.workspace .user-actions a { margin: 0; }
.user-actions .btn { font-size: 12px; padding: 5px 10px; min-height: 32px; border-radius: 8px; }
@media (max-width: 800px) { .assignment-grid { grid-template-columns: 1fr; } .assignment-summary { flex-direction: column; align-items: stretch; } .assignment-submit { justify-content: space-between; } }

/* Question version cards. */
.question-preview { display: grid; gap: 22px; max-width: 1100px; margin: auto; }
.question-preview > p { margin: 0; }
.question-preview .surface { min-width: 0; overflow-wrap: anywhere; }
.question-heading { background: linear-gradient(120deg, #edf8f2, #fff); }
.question-heading h1 { font-size: clamp(23px, 3vw, 34px); margin-bottom: 16px; }
.question-heading p { color: var(--muted); font-size: 13px; margin: 0; }
.question-preview h2 { font-size: 20px; margin: 0 0 22px; }
.question-preview h3 { font-size: 17px; margin: 26px 0 12px; }
.question-content { border-top: 4px solid var(--teal); }
.question-prompt { font-size: 19px; line-height: 1.75; }
.question-content audio { width: 100%; }
.question-content img { display: block; margin-inline: auto; border-radius: 12px; object-fit: contain; }
.question-content iframe { border-radius: 12px; }
.question-options { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.question-option { display: flex; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; line-height: 1.65; }
.question-option-number { flex-shrink: 0; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #edf1f0; font-weight: 600; }
.question-option-correct { background: #eff9f3; border-color: #8ac6a2; }
.question-option-correct .question-option-number { background: #d6efdf; color: #17653a; }
.question-option strong { display: block; font-size: 12px; margin-top: 8px; }
.question-answer > p { line-height: 1.8; }
.question-concepts { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.question-concepts li { padding: 9px 13px; background: #edf6f1; border: 1px solid #cee3d8; border-radius: 10px; font-size: 13px; }
.question-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.question-actions p, .question-actions form { margin: 0; }
.question-history ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.question-history li { border-left: 3px solid var(--teal); background: #f6f9f8; border-radius: 0 10px 10px 0; padding: 14px; font-size: 13px; line-height: 1.8; }
@media (max-width: 600px) { .question-prompt { font-size: 17px; } .question-option { padding: 14px; gap: 10px; } }

/* Compact exam settings cards. */
.exam-settings { max-width: 1120px; margin: auto; }
.exam-settings .page-heading { margin-bottom: 22px; }
.exam-settings .page-heading h1 { font-size: clamp(24px, 3vw, 34px); }
.exam-settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.exam-settings-card { padding: 20px; min-width: 0; }
.exam-settings-card h2 { font-size: 17px; margin: 0 0 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.exam-settings-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.exam-settings-field { min-width: 0; }
.exam-settings-field label { display: block; font-size: 12px; line-height: 1.4; margin-bottom: 6px; }
.exam-settings-field input:not([type='checkbox']), .exam-settings-field textarea { width: 100%; min-width: 0; padding: 8px 11px; font-size: 13px; border: 1px solid #bfd5ce; border-radius: 9px; background: #fbfdfc; }
.exam-settings-field input:not([type='checkbox']) { height: 38px; }
.exam-settings-field textarea { min-height: 100px; resize: vertical; }
.exam-settings-field input:focus-visible, .exam-settings-field textarea:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.exam-settings-toggle { align-self: end; }
.exam-settings-toggle label { display: flex; align-items: center; gap: 9px; min-height: 38px; margin: 0; }
.exam-settings-toggle input { width: 18px; height: 18px; accent-color: var(--teal); }
.exam-settings-wide { grid-column: 1 / -1; }
.exam-settings-wide .exam-settings-fields { grid-template-columns: 1fr; }
.exam-settings-field .errorlist { font-size: 12px; margin: 6px 0 0; }
.exam-settings-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; }
@media (max-width: 800px) { .exam-settings-grid { grid-template-columns: 1fr; } }
@media (max-width: 400px) { .exam-settings-fields { grid-template-columns: 1fr; } }
/* Subject details, mobile table scrolling, and question editor. */
.logout-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    margin-left: 6px;
    padding: 8px 12px;
    border: 1px solid #8fbab1;
    background: #edf6f1;
    color: var(--teal-dark);
    white-space: nowrap;
}
.logout-button:hover { background: var(--mint); color: var(--teal-dark); }
.subject-detail { display: grid; gap: 18px; max-width: 1100px; }
.subject-detail .surface { min-width: 0; overflow-wrap: anywhere; }
.subject-overview { background: linear-gradient(120deg, #edf8f2, #fff); }
.subject-detail-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.workspace .subject-detail-actions a { margin: 0; }
.subject-detail .btn { display: inline-flex; align-items: center; gap: 8px; }
.assignment-history { list-style: none; padding: 0; margin: 0; }
.assignment-history li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.assignment-history li:last-child { border-bottom: 0; padding-bottom: 0; }
.scrollable-table { width: 100%; max-width: 100%; overflow-x: auto; }
.question-bank-table { min-width: 800px; }
.question-bank-table th:nth-child(1) { width: 20%; }
.question-bank-table th:nth-child(2) { width: 38%; }
.scrollable-table .ranking-table { min-width: 600px; }
.question-editor { max-width: 1100px; margin: auto; }
.question-editor .page-heading { margin-bottom: 16px; }
.question-editor h1 { font-size: clamp(22px, 2.6vw, 32px); }
.question-editor .page-heading p { font-size: 13px; margin-bottom: 8px; }
.compact-question-form { padding: 20px; }
.question-fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.question-field { grid-column: span 3; min-width: 0; }
.question-field[data-field='delivery_type'],
.question-field[data-field='answer_type'],
.question-field[data-field='difficulty'] { grid-column: span 2; }
.question-field[data-field='prompt_text'],
.question-field[data-field='change_note'] { grid-column: 1 / -1; }
.question-field label { font-size: 12px; }
.question-field textarea { line-height: 1.5; }
.question-field .helptext { font-size: 11px; }
.compact-question-form #options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.compact-question-form #options fieldset { min-width: 0; margin: 0 !important; }
.compact-question-form #options p { margin-bottom: 8px; }
.compact-question-form #add-option { margin-top: 12px; }
.compact-question-form > button[type='submit'] { margin-top: 18px; }
@media (max-width: 600px) {
    .compact-question-form { padding: 16px; }
    .question-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .question-field { grid-column: 1 / -1; }
    .question-field[data-field='delivery_type'],
    .question-field[data-field='answer_type'] { grid-column: span 1; }
    .question-field[data-field='difficulty'] { grid-column: 1 / -1; }
    .compact-question-form #options { grid-template-columns: 1fr; }
}

/* Subject totals and the daily exam chart. */
.subject-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.subject-stat { position: relative; min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.subject-stat > span:not(.subject-stat-icon) { display: block; margin-top: 14px; font-size: 12px; color: var(--muted); }
.subject-stat > strong { display: block; margin: 8px 0; font-size: 34px; line-height: 1.15; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.subject-stat small { display: block; font-size: 11px; line-height: 1.5; }
.subject-stat-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; background: var(--mint); color: var(--teal); }
.subject-stat-icon svg { width: 20px; height: 20px; }
.subject-stat:nth-child(2) .subject-stat-icon { background: #e5effb; color: #34649a; }
.subject-stat:nth-child(3) .subject-stat-icon { background: #fff2d9; color: #8d651b; }
.subject-stat:nth-child(4) .subject-stat-icon { background: #efeafa; color: #71559e; }
.subject-activity-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.subject-activity-heading h2 { margin: 0 0 8px; }
.subject-activity-heading p { margin: 0; font-size: 12px; color: var(--muted); }
.subject-period-total { padding: 12px 18px; border-radius: 12px; background: #edf6f1; }
.subject-period-total strong { font-size: 28px; color: var(--teal-dark); margin-right: 8px; }
.subject-period-total span { font-size: 12px; }
.subject-chart-summary { display: flex; flex-wrap: wrap; gap: 10px 24px; margin: 20px 0 12px; font-size: 12px; color: var(--muted); }
.subject-chart-summary strong { color: var(--ink); }
.subject-chart-scroll { overflow-x: auto; max-width: 100%; }
.subject-chart { display: grid; grid-template-columns: repeat(30, minmax(24px, 1fr)); gap: 7px; min-width: 940px; padding: 28px 4px 10px; margin: 0; list-style: none; }
.subject-chart-track { height: 160px; display: flex; align-items: flex-end; border-bottom: 1px solid #a8c9bf; background: repeating-linear-gradient(to top, #eaf0ed 0, #eaf0ed 1px, transparent 1px, transparent 40px); }
.subject-chart-bar { position: relative; width: 100%; border-radius: 5px 5px 0 0; background: linear-gradient(to top, #08786e, #61b49b); }
.subject-chart-bar > span { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 600; color: var(--teal-dark); }
.subject-chart-zero { min-height: 2px; background: #cddbd5; }
.subject-chart-zero > span { color: var(--muted); font-weight: 400; }
.subject-chart-date { display: block; text-align: center; margin-top: 8px; font-size: 9px; white-space: nowrap; color: var(--muted); }
.subject-chart-note, .subject-chart-empty { color: var(--muted); font-size: 12px; margin: 14px 0 0; }
.subject-chart-empty { background: #f3f7f5; padding: 12px; border-radius: 8px; }
@media (max-width: 1100px) { .subject-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .subject-stat-grid { gap: 10px; } .subject-stat { padding: 15px; } .subject-stat > strong { font-size: 28px; } .subject-period-total { width: 100%; } }

/* A consistently aligned handbook contents list at every screen size. */
.handbook-toc {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 18px;
    align-content: start;
}
.handbook-toc > .eyebrow { margin: 0 0 4px; }
.workspace .handbook-toc a {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    align-items: center;
    justify-content: start;
    gap: 10px;
    width: 100%;
    min-height: 46px;
    margin: 0;
    padding: 10px;
    text-align: left;
    line-height: 1.45;
}
.handbook-toc .toc-number {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: #fff;
    color: var(--teal);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}
.handbook-toc .toc-label { min-width: 0; overflow-wrap: normal; }
@media (min-width: 601px) and (max-width: 900px) {
    .handbook-toc { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .handbook-toc > .eyebrow { grid-column: 1 / -1; }
}
@media (min-width: 901px) {
    .handbook-layout { grid-template-columns: 260px minmax(0, 1fr); }
}

/* Decorative icons for analytics metric cards. */
.metrics-cards { gap: 12px; margin: 18px 0 22px; }
.metrics-cards .stat-card {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    align-content: center;
    align-items: center;
    column-gap: 12px;
    row-gap: 4px;
    padding: 16px 18px;
    border-radius: 14px;
}
.metrics-cards .stat-card::before { top: 50%; transform: translateY(-50%); height: 24px; }
.metrics-cards .stat-card > span { font-size: 12px; line-height: 1.4; }
.metrics-cards .stat-card > strong { margin: 0; font-size: 26px; line-height: 1.15; }
.metrics-cards .metric-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    grid-row: span 2;
    width: 36px;
    height: 36px;
    margin: 0;
    border-radius: 10px;
    background: var(--mint);
    color: var(--teal);
}
.metrics-cards .stat-card:nth-child(3n + 2) .metric-icon { background: #e5effb; color: #34649a; }
.metrics-cards .stat-card:nth-child(3n) .metric-icon { background: #efeafa; color: #71559e; }
@media (max-width: 600px) {
    .metrics-cards { gap: 10px; }
    .metrics-cards .stat-card { padding: 12px; column-gap: 8px; grid-template-columns: 28px minmax(0, 1fr); }
    .metrics-cards .metric-icon { width: 28px; height: 28px; border-radius: 8px; }
    .metrics-cards .metric-icon svg { width: 18px; height: 18px; }
    .metrics-cards .stat-card > span { font-size: 11px; }
    .metrics-cards .stat-card > strong { font-size: 22px; }
}

.metrics-group { margin-bottom: 24px; }
.metrics-group > h2 { margin: 0 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 16px; }
.metrics-group .metrics-cards { margin: 0; }

/* Compact user list totals. */
.user-summary { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.user-summary .stat-card { min-width: 150px; padding: 12px 16px; border-radius: 12px; }
.user-summary .stat-card::before { top: 16px; height: 22px; }
.user-summary .stat-card > strong { display: inline-block; margin-top: 6px; font-size: 24px; }
.user-summary .stat-card > small { margin-left: 8px; color: var(--muted); font-size: 11px; }
@media (max-width: 600px) {
    .user-summary .stat-card { flex: 1 1 130px; min-width: 0; }
}
