﻿:root {
    --bg: #f4f4f5;
    --surface: #ffffff;
    --text: #1f1f1f;
    --muted: #666;
    --border: #d4d4d8;
    --primary: #1f4b99;
    --primary-text: #fff;
    --danger: #9b1c1c;
    --danger-bg: #fee2e2;
    --info-bg: #e0f2fe;
    --ok: #166534;
    --warn: #9a3412;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
    line-height: 1.7;
}

a {
    color: var(--primary);
}

.admin-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.admin-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: #111827;
    color: #fff;
    flex-wrap: wrap;
}

.admin-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
}

.admin-nav {
    display: flex;
    gap: 1rem;
    flex: 1;
    flex-wrap: wrap;
}

.admin-nav a {
    color: #e5e7eb;
    text-decoration: none;
}

.admin-nav a.active {
    color: #fff;
    text-decoration: underline;
}

.nav-count-badge {
    display: inline-block;
    margin-inline-start: 0.35rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: #b91c1c;
    color: #fff;
    vertical-align: middle;
}

.device-alert-high {
    border-color: #b91c1c;
    border-width: 2px;
}

.device-alert-warn {
    border-color: #d97706;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.admin-user-email {
    color: #fff;
    font-weight: 600;
}

.admin-user-roles {
    color: #9ca3af;
    font-size: 0.85rem;
}

.admin-signout {
    background: transparent;
    border-color: #4b5563;
    color: #e5e7eb;
}

.admin-signout:hover {
    border-color: #9ca3af;
    color: #fff;
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-panel {
    width: 100%;
    max-width: 26rem;
    margin: 0;
}

.login-panel h1 {
    margin-top: 0;
}

.admin-main {
    padding: 1.25rem;
    max-width: 1400px;
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-header h1 {
    margin: 0.25rem 0;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

.analyze-action {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-width: 18rem;
}

.analyze-action-wide {
    max-width: 22rem;
}

.analysis-selection-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.analysis-lesson-picker {
    margin: 0 0 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.analysis-lesson-picker legend {
    padding-inline: 0.35rem;
    font-weight: 700;
}

.analysis-lesson-picker .analysis-selection-controls {
    margin-block: 0.65rem;
}

.analysis-lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: 0.45rem;
    max-height: 24rem;
    overflow-y: auto;
}

.analysis-lesson-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    min-height: 3.25rem;
    padding: 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}

.analysis-lesson-option.is-selected {
    border-color: var(--primary);
    background: #f0f7ff;
}

.analysis-lesson-option input {
    flex: 0 0 auto;
    width: 1.1rem;
    height: 1.1rem;
    margin-block-start: 0.15rem;
    accent-color: var(--primary);
}

.analysis-lesson-copy {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.analysis-lesson-copy strong {
    overflow-wrap: anywhere;
}

.analysis-lesson-status {
    display: inline-flex;
    flex: 0 0 auto;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: #ecfdf3;
    color: #166534;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.node-analysis-check {
    display: inline-flex;
    align-items: center;
    margin: 0;
    cursor: pointer;
}

.node-analysis-check input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
    cursor: pointer;
}

.analyze-hint {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.35;
}

/* Pupils about to overtake the analysis. Loud enough to be read before the buttons
   beneath it are pressed, because it is the reason to press one of them. */
.near-end-warning {
    margin: 0 0 0.5rem;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    border: 1px solid #E0A800;
    background-color: #FFF6DC;
    color: #6B4E00;
    font-size: 0.87rem;
    font-weight: 600;
    line-height: 1.5;
}

/* Quiet setting under the one analyse button: which depth to run, not a second action. */
.analyze-mode {
    margin: 0.15rem 0 0;
    padding: 0.35rem 0 0;
    border: 0;
    border-block-start: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.analyze-mode:disabled {
    opacity: 0.55;
}

.analyze-mode-option {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.5rem;
    margin: 0;
    padding-inline: 0.1rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.analyze-mode-option input {
    margin: 0;
    flex-shrink: 0;
}

.analyze-mode-label {
    font-weight: 600;
}

.analyze-mode-desc {
    flex-basis: 100%;
    margin-inline-start: 1.35rem;
    font-size: 0.8rem;
    line-height: 1.3;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* The three stages a book goes through, drawn in the header so that "which button now" is
   answered before anyone reaches for one. Reads right to left with the rest of the page. */
.workflow-steps {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 0 0.5rem;
    padding: 0;
    list-style: none;
    font-size: 0.85rem;
}

.workflow-steps .step {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
    color: var(--muted, #6b7280);
}

.workflow-steps .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 1px solid var(--border);
    font-weight: 700;
}

/* The step being worked on is the only one that carries weight; a finished one is confirmed but
   quiet, and one not reached yet says nothing at all. */
.workflow-steps .step-current {
    color: var(--primary, #1d4ed8);
    font-weight: 700;
}

.workflow-steps .step-current .step-num {
    border-color: currentColor;
    background: var(--primary, #1d4ed8);
    color: #fff;
}

.workflow-steps .step-done .step-num {
    border-color: var(--success, #16a34a);
    color: var(--success, #16a34a);
}

.workflow-steps .step-todo {
    opacity: 0.55;
}

.workflow-steps .step-blocked {
    color: var(--danger, #9b1c1c);
    font-weight: 700;
}

.workflow-steps .step-blocked .step-num {
    border-color: var(--danger, #9b1c1c);
    background: var(--danger-bg, #fee2e2);
    color: var(--danger, #9b1c1c);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.panel-danger {
    border-color: #f0b4b4;
    background: #fff8f8;
}

.panel-danger h2 {
    color: var(--danger);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.panel h2, .panel h3 {
    margin: 0 0 0.75rem;
}

.panel summary {
    cursor: pointer;
    font-weight: 600;
}

.exam-review-pagination-toolbar,
.exam-review-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.exam-review-pagination-toolbar {
    margin-top: 1rem;
}

.exam-review-page-size {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.exam-review-page-size .input {
    width: auto;
    min-width: 5rem;
}

.exam-review-pagination {
    margin: 1rem 0 2rem;
}

.muted {
    color: var(--muted);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

th, td {
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.6rem;
    text-align: right;
    vertical-align: top;
}

th {
    background: #fafafa;
}

.btn {
    display: inline-block;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    padding: 0.35rem 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-text);
}

.btn-secondary {
    background: #fff;
}

.btn-danger {
    color: var(--danger);
    border-color: #f0b4b4;
}

.btn-small {
    padding: 0.15rem 0.4rem;
    font-size: 0.85rem;
}

.banner {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.banner-error {
    background: var(--danger-bg);
    color: var(--danger);
}

.banner-info {
    background: var(--info-bg);
}

.banner ul {
    margin: 0.3rem 0 0;
}

.status-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
}

.status-uploaded { background: #f4f4f5; }
.status-draft { background: #fef3c7; color: var(--warn); }
.status-approved { background: #dbeafe; }
.status-busy { background: #ede9fe; }
.status-done { background: #dcfce7; color: var(--ok); }
.status-failed { background: var(--danger-bg); color: var(--danger); }

.form-grid {
    display: grid;
    gap: 0.85rem;
    max-width: 40rem;
    margin-bottom: 1rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

input, select, textarea, .input-title {
    font: inherit;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.input-narrow {
    width: 5.5rem;
}

.inline-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(16rem, 0.9fr);
    gap: 1rem;
    align-items: start;
}

@media (max-width: 900px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
}

.node-tree {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.node-block {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.4rem;
    background: #fff;
}

.node-selected {
    outline: 2px solid var(--primary);
}

.node-invalid {
    border-color: var(--danger);
    background: #fff8f8;
}

.node-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    cursor: pointer;
}

.node-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.warning-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    white-space: nowrap;
}

.node-visibility-select {
    padding: 0.15rem 0.35rem;
    font-size: 0.82rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}

.node-visibility-select.is-hidden {
    border-color: #f87171;
    background: #fef2f2;
    color: #991b1b;
}

.node-visibility-select.is-kept {
    border-color: #86efac;
    background: #f0fdf4;
    color: #166534;
}

.input-title {
    min-width: 12rem;
    flex: 1;
}

.node-pdf {
    font-size: 0.85rem;
}

.node-errors {
    color: var(--danger);
    margin: 0.35rem 0 0;
}

.preview-pane {
    position: sticky;
    top: 0.75rem;
}

.preview-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: end;
    margin-bottom: 0.75rem;
}

.page-image {
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
}

.progress-track {
    height: 0.6rem;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin: 0.4rem 0 0.75rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
}

.row-failed {
    background: #fff1f1;
}

.content-block {
    border-top: 1px solid var(--border);
    padding: 0.75rem 0;
}

.pre-wrap {
    white-space: pre-wrap;
}

.question-list {
    padding-right: 1.2rem;
}

.question-item {
    margin-bottom: 1rem;
}

.question-item pre {
    white-space: pre-wrap;
    background: #fafafa;
    padding: 0.5rem;
    border: 1px solid var(--border);
}

.question-figure-review {
    margin: 0.75rem 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 40rem;
}

.question-figure-crop {
    /* Large enough to tell a map from neighbouring paragraph text — a thumbnail cannot do that job. */
    width: 100%;
    max-height: 28rem;
    height: auto;
    object-fit: contain;
    object-position: top;
    border: 1px solid var(--border);
    background: #fafafa;
}

.question-figure-page-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.figure-page-with-box {
    position: relative;
    width: 100%;
    border: 1px solid var(--border);
}

.figure-page-with-box .page-image {
    display: block;
    width: 100%;
    height: auto;
    border: 0;
}

.figure-box-marker {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    pointer-events: none;
}

.lookup-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.lookup-list li {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.subject-icon {
    width: 1.5rem;
    height: 1.5rem;
    object-fit: contain;
    vertical-align: middle;
    margin-left: 0.35rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    left: 0.75rem;
    top: 0.5rem;
}

/* Teacher pages */
.attention-band {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.attention-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    text-align: center;
}

.attention-card-active {
    outline: 2px solid var(--primary);
}

.attention-card-danger .attention-count {
    color: var(--danger);
}

.attention-count {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.attention-label {
    font-size: 0.9rem;
    color: var(--muted);
}

.attention-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 1rem;
}

.stuck-lessons-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stuck-lessons-list p {
    margin: 0;
}

.stuck-lesson-book {
    font-size: 0.9rem;
    margin-top: 0.15rem;
}

.join-code-display {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--primary);
    margin: 0.5rem 0 0.75rem;
    user-select: all;
}

.join-code-closed {
    font-weight: 600;
    margin: 0.5rem 0 0.75rem;
}

.join-code-hint {
    margin: 0.75rem 0 0.5rem;
}

.auto-approve-toggle {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    cursor: pointer;
}

.auto-approve-toggle input {
    width: auto;
    margin: 0;
}

.saved-indicator {
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

.roster-search {
    margin-bottom: 0.75rem;
    max-width: 20rem;
}

.never-started {
    color: var(--danger);
}

.num-cell {
    text-align: left;
}

.pupil-headline {
    font-size: 15px;
    margin: 0 0 1rem;
    line-height: 1.7;
}

.activity-strip-wrap {
    margin-bottom: 1rem;
}

.activity-strip {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 3rem;
}

.activity-bar {
    flex: 1;
    min-width: 4px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
    min-height: 4px;
}

.activity-bar-zero {
    background: #e5e7eb;
    height: 4px;
}

.activity-strip-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.35rem;
    font-size: 0.85rem;
}

.next-step-panel {
    border-inline-start: 4px solid var(--primary);
    border-radius: 0;
}

.pupil-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.pupil-card h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.pupil-card-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.score-ok {
    color: var(--ok);
}

.score-warn {
    color: var(--warn);
}

.pupil-points {
    font-size: 0.9rem;
    margin: 0;
}

@media (max-width: 700px) {
    .teacher-table thead {
        display: none;
    }

    .teacher-table,
    .teacher-table tbody,
    .teacher-table tr,
    .teacher-table td {
        display: block;
        width: 100%;
    }

    .teacher-table tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 6px;
        margin-bottom: 0.75rem;
        padding: 0.5rem 0.75rem;
    }

    .teacher-table td {
        border: none;
        padding: 0.35rem 0;
        text-align: right;
    }

    .teacher-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--muted);
        margin-bottom: 0.15rem;
    }

    .teacher-table td:last-child {
        padding-top: 0.5rem;
    }

    .teacher-table td:last-child::before {
        display: none;
    }

    .teacher-table .num-cell {
        text-align: right;
    }
}

/* ==========================================================================
   Global Print Stylesheet
   Why: When any admin or reviewer triggers browser printing (e.g. printing a lesson),
   the global shell chrome (dark admin top header, blazor error dialogs) must not
   appear on physical paper or PDF exports, and the main container must span full width.
   ========================================================================== */
@media print {
    .admin-header,
    #blazor-error-ui {
        display: none !important;
    }

    .admin-main {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
}

/* ── Question-type mix per grade ──
   Four percentages that must add to 100. The live total is the whole point of the
   layout: it turns "did I get that right?" into something the eye answers, and the
   save button stays disabled until it says 100. */
.mix-table .mix-input {
    width: 4.5rem;
    text-align: center;
    padding-inline: 0.3rem;
}

.mix-grade {
    white-space: nowrap;
    font-weight: 600;
}

.mix-default-tag {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
}

.mix-total {
    font-weight: 700;
    white-space: nowrap;
}

.mix-total.is-ok {
    color: #15803D;
}

.mix-total.is-off {
    color: #B45309;
}

.mix-blank-hint {
    font-size: 0.75rem;
    font-weight: 400;
}

.mix-actual {
    font-size: 0.82rem;
    white-space: nowrap;
}

.mix-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* Essay is the only type that costs money every time a child answers one, so the
   warning sits above the table rather than in a tooltip nobody opens. */
.mix-cost-note {
    margin: 0 0 1rem;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    border: 1px solid #E0A800;
    background-color: #FFF6DC;
    color: #6B4E00;
    font-size: 0.87rem;
    line-height: 1.6;
}

/* ── Books list: filters ──
   One row of controls above the table, each with its label above it rather than
   beside it, so the row stays readable when a select widens to fit «الدراسات
   الاجتماعية». The count line underneath is deliberately always shown: it is the
   answer to "where did my book go?", and that question gets asked exactly when
   someone has forgotten a filter is on. */
.book-filters {
    margin-bottom: 1rem;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 8.5rem;
}

.filter-field-wide {
    flex: 1 1 16rem;
    min-width: 12rem;
}

.filter-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #52525B;
}

.filter-clear {
    margin-block-end: 0.1rem;
}

.filter-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-block-start: 0.75rem;
    padding-block-start: 0.6rem;
    border-block-start: 1px solid var(--border);
}

.filter-count {
    margin-inline-end: auto;
    font-size: 0.87rem;
    color: #3F3F46;
}

/* A deleted book, in its own view. Faded rather than struck through: it is still
   fully readable, because the reason to be on this screen is to find one and
   bring it back. */
.row-deleted td {
    opacity: 0.7;
}

.confirm-text {
    max-width: 34rem;
    line-height: 1.6;
}

/* Questions on the row. The count is the reason a reviewer opens this list; the
   badge beside it is how many nobody has read yet, which is the work remaining. */
.book-questions {
    white-space: nowrap;
}

.pending-badge {
    display: inline-block;
    margin-inline-start: 0.35rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background-color: #FEF3C7;
    color: #7C4A03;
    border: 1px solid #FCD34D;
    font-size: 0.75rem;
    font-weight: 700;
}

/* ── Subscription state on an account row ── */
.sub-cell { white-space: nowrap; }

.sub-on {
    padding: 0.1rem 0.45rem;
    border-radius: 6px;
    background-color: #DCFCE7;
    color: #166534;
    border: 1px solid #86EFAC;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Marked distinctly from a paid subscription on purpose: a grant is not revenue, and
   the row should never let someone read it as one. */
.sub-comp {
    margin-inline-start: 0.25rem;
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    background-color: #EDE9FE;
    color: #5B21B6;
    border: 1px solid #C4B5FD;
    font-size: 0.72rem;
    font-weight: 700;
}

.sub-ends {
    display: block;
    font-size: 0.72rem;
}

/* ── Stage card (pipeline stage card with state accent border) ── */
.stage-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-inline-start: 4px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.stage-card.stage-done {
    border-left-color: var(--ok, #166534);
    border-inline-start-color: var(--ok, #166534);
}

.stage-card.stage-current {
    border-left-color: var(--primary, #1f4b99);
    border-inline-start-color: var(--primary, #1f4b99);
}

.stage-card.stage-blocked {
    border-left-color: var(--danger, #9b1c1c);
    border-inline-start-color: var(--danger, #9b1c1c);
}

.stage-card.stage-todo {
    border-left-color: var(--border, #d4d4d8);
    border-inline-start-color: var(--border, #d4d4d8);
}

.stage-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.stage-card-title-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.stage-card-title-group h2,
.stage-card-title-group h3 {
    margin: 0;
}

.stage-card-toggle {
    margin-inline-start: auto;
}

.stage-blocked-reason {
    margin: 0.5rem 0;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
}

.stage-hint {
    margin: 0.5rem 0;
}

.stage-primary-action {
    margin: 0.75rem 0;
}

.stage-card-content {
    margin-top: 0.75rem;
}

/* ── Overflow dropdown menu ── */
.overflow-menu-container {
    position: relative;
    display: inline-block;
}

.overflow-menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    background: transparent;
}

.overflow-menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline-end: 0;
    margin: 0;
    padding: 0.35rem 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    z-index: 101;
    min-width: 12rem;
}

.overflow-menu-dropdown .menu-item {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: start;
    padding: 0.5rem 0.85rem;
    font: inherit;
    font-size: 0.875rem;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--text);
    white-space: nowrap;
}

.overflow-menu-dropdown .menu-item:hover:not(:disabled) {
    background: var(--bg);
}

.overflow-menu-dropdown .menu-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.overflow-menu-dropdown .menu-item-danger {
    color: var(--danger);
}

.overflow-menu-dropdown .menu-item-danger:hover:not(:disabled) {
    background: var(--danger-bg);
}

.overflow-menu-disabled {
    pointer-events: none;
    opacity: 0.6;
}

/* ── Filter chips ── */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    line-height: 1.4;
    transition: all 0.15s ease;
}

.filter-chip:hover {
    border-color: var(--primary);
}

.filter-chip.chip-active {
    background: var(--primary);
    color: var(--primary-text, #fff);
    border-color: var(--primary);
    font-weight: 600;
}

.filter-chip.chip-danger {
    color: var(--danger);
    border-color: #f0b4b4;
}

.filter-chip.chip-danger.chip-active {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

/* ── Approval bar (sticky above drafts list) ── */
.approval-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.approval-bar-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.approval-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-inline-start: auto;
}


/* ── Text link verification & lesson evidence ── */
.link-verdict {
    margin: 0.5rem 0 0.25rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.link-verdict.ok {
    color: var(--ok);
}

.link-verdict.warn {
    color: var(--warn);
}

.evidence-quote {
    margin: 0.5rem 0 0.25rem;
    padding: 0.5rem 0.75rem;
    border-inline-start: 3px solid var(--ok);
    background: var(--info-bg);
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.8;
    white-space: pre-wrap;
}

.evidence-caption {
    font-size: 0.8rem;
    margin: 0 0 0.5rem;
}

.alt-candidates {
    margin: 0.5rem 0;
}

.alt-candidates summary {
    color: var(--muted);
    cursor: pointer;
    font-size: 0.9rem;
    user-select: none;
}

.tag {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    vertical-align: middle;
}

.tag-info {
    background: var(--info-bg);
    color: var(--primary);
}

.bulk-approval-scope {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    border: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}

.bulk-scope-legend {
    font-size: 0.85rem;
    font-weight: 600;
    margin-inline-end: 0.25rem;
    padding: 0;
}

.bulk-scope-option {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.bulk-scope-hint {
    font-size: 0.75rem;
}

.primary-stage-action {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.stage-action-hint {
    font-size: 0.8rem;
    margin: 0;
}
