/* Task 19 (spec §7.9): the classes screen, the grade filter chips, the new-school-year wizard and the
   archive viewer. Tokens only (tokens.css), so the three designs and dark mode follow on their own. */

/* ---- the grade filter bar over results / students / questions ---- */
.t-grade-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s3); margin-block-end: var(--s4); min-width: 0; }
.t-grade-bar .t-grade-help { flex-basis: 100%; margin: 0; }
.t-cert-grade { display: flex; flex-direction: column; gap: 6px; margin-block: var(--s2); }
.t-cert-grade[hidden] { display: none; }
.t-grade-bar[hidden] { display: none; }
.t-grade-l { display: inline-flex; align-items: center; gap: 6px; flex: none; font-family: var(--f-head); font-weight: 600; font-size: 15.5px; color: var(--muted); }
.t-grade-l i { font-size: 20px; color: var(--primary); }
.t-grade-bar #t-grade-chips { min-width: 0; flex: 1; }
.t-stage-grade { display: flex; flex-direction: column; gap: 4px; }
.t-stage-grade[hidden] { display: none; }

/* ---- classes, grouped by grade ---- */
.cy-top-h { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.cy-top-h .lbl b { display: block; font-family: var(--f-head); font-weight: 600; font-size: 16.5px; color: var(--text); }
.cy-top-h > .btn { flex: none; }
.cy-grades { display: flex; flex-direction: column; gap: var(--s4); margin-block-start: var(--s2); }
.cy-grade-h { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; min-height: 36px; }
.cy-grade-h h3 { display: inline-flex; align-items: center; gap: var(--s2); font-family: var(--f-head); font-weight: 600; font-size: 16.5px; color: var(--text); }
.cy-grade-h h3 i { font-size: 24px; color: var(--primary); }
.cy-grade-h .t-mu { font-size: 14.5px; }
.cy-grade-h .btn { margin-inline-start: auto; }
.cy-classes { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: var(--s2); }
.cy-class { display: flex; align-items: center; gap: var(--s3); min-height: 60px; padding: var(--s2) var(--s3); border-radius: var(--r-btn); border: 1px solid var(--border); background: var(--surface); }
.cy-class.is-archived { border-style: dashed; background: transparent; }
.cy-class.is-archived .cy-nm b { color: var(--muted); }
.cy-ic { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--tint); color: var(--on-tint); font-size: 22px; }
.cy-class.is-archived .cy-ic { background: var(--surface-2); color: var(--muted); }
.cy-nm { flex: 1; min-width: 0; }
.cy-nm b { display: block; font-family: var(--f-head); font-weight: 600; font-size: 15.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cy-nm small { display: block; color: var(--muted); font-size: 13px; }
.cy-class .t-acts { display: flex; gap: 4px; flex: none; }
.cy-year { border-block-start: 1px solid var(--border); }
.cy-year-acts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s3); }
.cy-year-acts .btn { width: 100%; }
.cy-n { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding-inline: 6px; border-radius: var(--r-pill); background: var(--surface); color: var(--text); font-size: 13px; font-family: var(--f-head); }
.cy-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.cy-row > div:first-child { min-width: 0; }
.cy-row b { font-family: var(--f-head); font-weight: 600; font-size: 15.5px; color: var(--text); }
.cy-row > .btn, .cy-row > div:last-child:not(:first-child) { flex: none; }
.cy-danger { color: var(--error) !important; }
.cy-small { font-size: 13px; }
.cy-last { margin-block-start: var(--s2); background: var(--surface-2); border-radius: var(--r-btn); padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.cy-last p { margin: 0; }

/* ---- dialogs (one at a time) ---- */
.cy-modal { z-index: 58; }
.cy-dlg-wide { max-width: 760px; }
.cy-dlg-body { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.cy-dlg-body fieldset { border: 0; padding: 0; margin: 0; }
.cy-form { display: flex; flex-direction: column; gap: var(--s3); }
.cy-inline { display: flex; gap: var(--s2); align-items: stretch; }
.cy-inline .t-txt { flex: 1; min-width: 0; }
.cy-inline .btn { flex: none; }
.cy-names { font-family: var(--f-body); line-height: 1.8; min-height: 160px; }
.bank-counter.is-over { color: var(--error); font-weight: 600; }
.cy-preview { min-height: 24px; }
.cy-preview p { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 15.5px; }
.cy-pv-line b { font-family: var(--f-head); font-weight: 600; color: var(--text); }
.cy-skip { list-style: none; margin: var(--s2) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; max-height: 140px; overflow-y: auto; }
.cy-skip li { display: inline-flex; align-items: center; gap: 4px; }
.cy-skip small { color: var(--muted); font-size: 13px; }
.cy-warn { color: var(--error); font-size: 15.5px; display: flex; align-items: center; gap: 6px; margin: 0; }
.cy-ok { color: var(--on-success); background: var(--success-tint); border-radius: var(--r-btn); padding: var(--s2) var(--s3); display: flex; align-items: center; gap: 6px; font-size: 15.5px; margin: 0; }
.cy-alert { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-btn); background: var(--reward-tint); color: var(--on-reward); }
.cy-alert > i { font-size: 24px; flex: none; margin-block-start: 2px; }
.cy-alert b { display: block; font-family: var(--f-head); font-weight: 600; font-size: 15.5px; }
.cy-alert p { margin: 4px 0 0; font-size: 15.5px; line-height: 1.6; }
.cy-alert .btn { margin-block-start: var(--s2); }
.cy-alert.is-danger { background: var(--error-tint, color-mix(in srgb, var(--error) 12%, var(--surface))); color: var(--text); }
.cy-alert.is-danger > i { color: var(--error); }
.cy-p { margin: 0; font-size: 15.5px; line-height: 1.7; color: var(--text); }

/* ---- the wizard ---- */
.yw-prog { display: flex; flex-direction: column; gap: var(--s2); }
.yw-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.yw-steps li { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; color: var(--muted); font-size: 13px; min-width: 0; }
.yw-steps .sn { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-family: var(--f-head); font-weight: 600; font-size: 14.5px; background: var(--surface-2); color: var(--muted); border: 1.5px solid var(--border); }
.yw-steps .sl { line-height: 1.3; }
.yw-steps li.is-on { color: var(--text); font-weight: 600; }
.yw-steps li.is-on .sn { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.yw-steps li.is-done .sn { background: var(--tint); border-color: var(--tint); color: var(--on-tint); }
.yw-prog .bar { height: 6px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.yw-prog .bar i { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width .3s ease; }
.yw-body { display: flex; flex-direction: column; gap: var(--s3); min-height: 220px; }
.yw-body h4 { display: flex; align-items: center; gap: var(--s2); font-family: var(--f-head); font-weight: 600; font-size: 17.5px; color: var(--text); outline: 0; }
.yw-body h4 i { color: var(--primary); font-size: 22px; }
.yw-body h4.yw-h5 { font-size: 16.5px; }
.yw-year { max-width: 220px; text-align: center; font-family: var(--f-head); }
.yw-foot { border-block-start: 1px solid var(--border); padding-block: var(--s3); margin-block-end: calc(-1 * var(--s3)); position: sticky; bottom: calc(-1 * var(--s4)); z-index: 2; background: var(--surface); }
html.dark .yw-foot { background: var(--surface-2); }
.yw-maps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.yw-map { display: grid; grid-template-columns: minmax(150px, 220px) 24px minmax(0, 1fr); align-items: center; gap: var(--s3); padding-block: var(--s3); border-block-start: 1px solid var(--border); }
.yw-map:first-child { border-block-start: 0; }
.yw-from { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.yw-from > i { font-size: 24px; color: var(--primary); flex: none; }
.yw-from b { display: block; font-family: var(--f-head); font-weight: 600; font-size: 15.5px; }
.yw-from small { color: var(--muted); font-size: 13px; }
.yw-arrow { color: var(--muted); font-size: 20px; display: grid; place-items: center; }
.yw-to { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.yw-ex { gap: var(--s2); }
.yw-search { display: flex; align-items: center; gap: var(--s2); border: 1.5px solid var(--border); border-radius: var(--r-btn); background: var(--surface); padding-inline: var(--s3); min-height: 44px; }
.yw-search i { color: var(--muted); font-size: 20px; }
.yw-search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font-size: 16.5px; outline: 0; min-height: 40px; }
.yw-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--tint); }
.yw-sugg, .yw-exlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.yw-sugg:empty, .yw-exlist:empty { display: none; }
.yw-pick { width: 100%; display: flex; align-items: center; gap: var(--s2); min-height: 44px; padding-inline: var(--s3); border-radius: var(--r-btn); border: 1px solid var(--border); background: var(--surface); color: var(--text); text-align: start; cursor: pointer; }
.yw-pick:hover, .yw-pick:focus-visible { border-color: var(--primary); }
.yw-pick i { color: var(--primary); }
.yw-pick b { font-weight: 500; font-size: 15.5px; }
.yw-pick small { color: var(--muted); font-size: 13px; margin-inline-start: auto; }
.yw-exrow { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s2) var(--s3); border-radius: var(--r-btn); background: var(--surface); border: 1px solid var(--border); }
.yw-exh { display: flex; align-items: center; gap: var(--s2); }
.yw-exh b { font-family: var(--f-head); font-weight: 600; font-size: 15.5px; }
.yw-exh small { color: var(--muted); font-size: 13px; }
.yw-exh .t-icon-btn { margin-inline-start: auto; }
.yw-lists { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s3); }
.yw-lists .cy-names { min-height: 130px; }
.yw-resets { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--s2); }
.yw-resets li { display: flex; align-items: center; gap: var(--s2); min-height: 44px; padding-inline: var(--s3); border-radius: var(--r-btn); background: var(--surface-2); font-size: 15.5px; color: var(--text); }
.yw-resets i { color: var(--primary); font-size: 22px; }
.yw-sum { margin: 0; font-family: var(--f-head); font-weight: 600; font-size: 22px; line-height: 1.5; color: var(--text); }
.yw-details { margin: 0; padding-inline-start: var(--s5); display: flex; flex-direction: column; gap: 4px; font-size: 15.5px; color: var(--text); }
.yw-creates { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 15.5px; }
.yw-confirm .t-txt { max-width: 260px; }
.yw-force { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; font-size: 15.5px; font-weight: 500; color: var(--text); cursor: pointer; }
.yw-force input { width: 20px; height: 20px; accent-color: var(--primary); }
.yw-done { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s3); padding-block: var(--s4); }
.yw-done-ic { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--tint); color: var(--primary); font-size: 42.5px; }
.yw-done h4 { justify-content: center; font-size: 21px; }
.yw-done p { margin: 0; max-width: 46ch; }

/* ---- the archive viewer ---- */
.ya-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.ya-item { width: 100%; display: flex; align-items: center; gap: var(--s3); min-height: 60px; padding-inline: var(--s3); border-radius: var(--r-btn); border: 1px solid var(--border); background: var(--surface); color: var(--text); text-align: start; cursor: pointer; }
.ya-item:hover, .ya-item:focus-visible { border-color: var(--primary); }
.ya-item > i:first-child { font-size: 24px; color: var(--primary); }
.ya-item div { flex: 1; min-width: 0; }
.ya-item b { display: block; font-family: var(--f-head); font-weight: 600; font-size: 16.5px; }
.ya-item small { color: var(--muted); font-size: 13px; }
.ya-go { color: var(--muted); }
.ya-head { display: flex; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.ya-title { font-family: var(--f-head); font-weight: 600; font-size: 17.5px; color: var(--text); margin: 0; }
.ya-title .t-mu { font-family: var(--f-body); font-weight: 400; font-size: 14.5px; }
.ya-tbl td, .ya-tbl th { white-space: nowrap; }

/* the stage modal's grade checkboxes */
.sm-grades { display: flex; flex-wrap: wrap; gap: var(--s2); }
.sm-grades label { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding-inline: var(--s3); border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); font-size: 15.5px; color: var(--text); cursor: pointer; }
.sm-grades label:has(input:checked) { border-color: var(--primary); background: var(--tint); color: var(--on-tint); font-weight: 500; }
.sm-grades input { width: 18px; height: 18px; accent-color: var(--primary); }
#sm-grades-box { border: 0; padding: 0; margin: 0; }
#sm-grades-box[hidden] { display: none; }

@media (max-width: 640px) {
    .yw-steps li:not(.is-on) .sl { display: none; }
    .yw-map { grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
    .yw-arrow { display: none; }
    .cy-row { flex-direction: column; align-items: stretch; }
    .cy-row > .btn { width: 100%; }
    .cy-top-h { flex-direction: column; align-items: stretch; }
    .cy-top-h > .btn { width: 100%; }
    .cy-inline { flex-direction: column; }
    .t-grade-bar { gap: var(--s2); }
    .cy-class .bl { display: none; } /* icon only; the button keeps its aria-label */
    .cy-nm b { white-space: normal; }
    .t-grade-l span, .t-grade-l { font-size: 14.5px; }
}
/* «رمز الفصل» beside each class */
.cy-code { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 12px; border-radius: 999px; cursor: pointer;
    border: 1.5px dashed var(--primary); background: var(--tint); color: var(--on-tint, var(--primary)); font: inherit; font-size: 14.5px; }
.cy-code b { font-size: 17px; font-weight: 900; letter-spacing: .08em; }
.cy-code:hover { background: color-mix(in srgb, var(--primary) 14%, var(--surface)); }
.cy-code-in { font-size: 22px; font-weight: 800; letter-spacing: .12em; text-align: center; }
@media (max-width: 520px) { .cy-code-l { display: none; } }
