/* Markly: base, shell and shared components. Colours, type, spacing and motion come from tokens.css; nothing here
   names a colour of its own. A screen is built from these components, and a feature stylesheet adds only what is its own.
   Order: base, shell, components, figures, script and comment pieces, smaller screens and touch, print. */

/* ------------------------------------------------------------------ base */
.mkly, .mkly *, .mkly *::before, .mkly *::after { box-sizing: border-box; }
html.mkly { background: var(--bg); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; }
body { font: 400 var(--fs-md)/var(--lh) var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
h1 { font-size: var(--fs-2xl); font-weight: 600; margin: 0 0 4px; letter-spacing: -0.02em; line-height: var(--lh-tight); }
h2 { font-size: var(--fs-lg); font-weight: 600; margin: 0 0 8px; letter-spacing: -0.01em; line-height: 1.3; }
h3 { font-size: var(--fs-sm); font-weight: 600; margin: 0 0 6px; color: var(--ink-2); line-height: 1.35; }
p { margin: 0 0 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-4) 0; }
::selection { background: hsl(146 50% 84%); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: var(--r-sm); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.skip { position: absolute; left: 8px; top: -48px; z-index: 100; padding: 8px 12px; border-radius: var(--r); background: var(--primary); color: var(--on-primary); }
.skip:focus { top: 8px; }

/* ------------------------------------------------------------------ shell: navigation beside the page */
body.app { display: grid; grid-template-columns: var(--nav-w, var(--nav-wide)) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh;
  transition: grid-template-columns var(--t-pane) var(--ease-inout); }
.mkly.nav-rail body.app { --nav-w: var(--nav-rail); }
.nav { position: sticky; top: 0; z-index: 30; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-3) var(--sp-2);
  border-right: 1px solid var(--line); background: var(--bg); min-width: 0; }
.nav-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-1); min-height: 40px; padding: 0 var(--sp-1) 0 var(--sp-2); margin-bottom: var(--sp-2); }
.logo { display: inline-flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); font-weight: 600; font-size: var(--fs-lg); letter-spacing: -0.02em; }
.logo:hover { text-decoration: none; }
.logo img { flex: none; }
.logo .lg { display: flex; flex-direction: column; line-height: 1.1; }
.logo small { font-size: var(--fs-2xs); font-weight: 500; letter-spacing: 0; color: var(--muted); margin-top: 2px; }
.nav nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.nav-grp { font-size: var(--fs-xs); font-weight: 500; color: var(--muted); padding: var(--sp-4) 12px var(--sp-1); white-space: nowrap; }
.nav-item { position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 12px; border-radius: var(--r); color: var(--ink-2); font-weight: 500;
  white-space: nowrap; transition: background var(--t-fast), color var(--t-fast); }
.nav-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--surface-3); color: var(--ink); font-weight: 600; }
.nav-item .ic { color: var(--muted); }
.nav-item[aria-current="page"] .ic { color: var(--green); }
.ic { width: 18px; height: 18px; flex: none; }
.ic.sm { width: 14px; height: 14px; }
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; transition: opacity var(--t-fast) var(--ease-inout) 60ms; }
.nav-user { display: flex; align-items: center; gap: 10px; padding: var(--sp-3) var(--sp-1) 0 var(--sp-2); margin-top: var(--sp-2); border-top: 1px solid var(--line); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 600; display: grid; place-items: center; flex: none; }
.nav-user .who { display: flex; flex-direction: column; flex: 1; line-height: 1.25; }
.nav-user .who b { font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-user .who small { color: var(--muted); font-size: var(--fs-xs); }
/* collapsed to icons: the labels stay for screen readers and come back as tips on hover and focus */
.nav-rail .nav { padding-left: 0; padding-right: 0; align-items: center; }
.nav-rail .nav-top { flex-direction: column; padding: 0; gap: var(--sp-2); }
.nav-rail .nav-label, .nav-rail .nav-grp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); opacity: 0; padding: 0; }
.nav-rail .nav nav { align-items: center; overflow: visible; }
.nav-rail .nav-item { width: 40px; min-height: 40px; padding: 0; justify-content: center; }
.nav-rail .nav-user { flex-direction: column; padding: var(--sp-3) 0 0; width: 40px; }
.nav-rail .nav-item::after { content: attr(data-tip); content: attr(data-tip) / ""; position: absolute; z-index: 60; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  padding: 4px 8px; border-radius: var(--r-sm); background: var(--ink); color: #fff; font: 500 var(--fs-xs)/1.3 var(--font); white-space: nowrap; pointer-events: none; opacity: 0;
  transition: opacity var(--t-fast); }
.nav-rail .nav-item:hover::after, .nav-rail .nav-item:focus-visible::after { opacity: 1; }
.topbar, .tabbar, .nav-scrim { display: none; }

.main { min-width: 0; }
.wrap { max-width: var(--page-max); margin: 0 auto; padding: var(--sp-6) var(--sp-8) var(--sp-12); }
body.plain .wrap { padding: var(--sp-5) var(--sp-5) var(--sp-12); }
.wrap.wide { max-width: none; padding: var(--sp-3) var(--sp-4); height: 100vh; height: 100dvh; min-height: 600px; display: flex; flex-direction: column; }

/* page header: where you are, what this is, its state, and the main action, always in the same places */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3) var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.head > :first-child { min-width: 0; flex: 1 1 320px; }
.head > :last-child:not(:first-child) { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; white-space: normal; }
.head .muted { max-width: 88ch; }
.head h1 .pill { vertical-align: 3px; margin-left: var(--sp-1); }
.crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--sp-1); }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--ink); }

/* ------------------------------------------------------------------ components */
/* cards and grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--sp-4); margin-bottom: var(--sp-3); }
.card.flush { padding: 0; overflow-x: auto; }      /* a table wider than its card scrolls inside it; nothing is cut off */
.card > h2:first-child { margin-bottom: var(--sp-3); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.card-h h2 { margin: 0; }
.card.flush > .card-h { padding: var(--sp-3) var(--sp-4); margin: 0; border-bottom: 1px solid var(--line); }
.grid { display: grid; gap: var(--sp-3); }
.grid > .card, .grid > form.card { margin-bottom: 0; }
.grid + .grid, .grid + .card, .card + .grid, .grid + .note, .note + .grid, .grid + form.card, .stats + .card, .stats + .grid { margin-top: var(--sp-3); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g2 > div > .card:last-child, .g-main > div > .card:last-child { margin-bottom: 0; }
@media (min-width: 761px) {
  /* student feedback page: the script stays in view while the student reads down the marks, the feedback and the comments */
  .fb { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .fb > :first-child { position: sticky; top: var(--sp-3); align-self: start; max-height: calc(100vh - 24px); overflow: auto; }
}

/* figures at a glance: a strip of small numbers, never a row of billboards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: var(--sp-3); }
.stat, .tile { background: var(--surface); padding: var(--sp-3) var(--sp-4); min-width: 0; }
.tile { border: 1px solid var(--line); border-radius: var(--r); }
.stat b, .tile b { display: block; font-size: var(--fs-xl); font-weight: 600; line-height: var(--lh-tight); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span, .tile span { color: var(--muted); font-size: var(--fs-xs); }
.stat b span, .tile b span { font-size: var(--fs-sm); font-weight: 500; }
.stat.attn b { color: var(--info); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: var(--fs-xs); color: var(--muted); font-weight: 500; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px var(--sp-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.card.flush > table tr:hover > td { background: hsl(60 10% 98.5%); }
td > a > b, td > b > a { color: var(--ink); }
tr.tot > td { background: var(--bg); border-top: 1px solid var(--line); }

/* status badges: the server's own lifecycle words, with a dot. Reading, ready for you, with you, approved, out, wrong */
.pill, .badge { display: inline-flex; align-items: center; gap: 6px; min-height: 20px; padding: 0 8px; border: 1px solid transparent; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 500; line-height: 1.2; white-space: nowrap; vertical-align: middle; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill.uploaded, .pill.transcribed { color: var(--muted); }
.pill.drafted { background: var(--info-bg); color: var(--info); }
.pill.in_review { background: var(--surface); border-color: var(--info-line); color: var(--info); }
.pill.approved { background: var(--surface); border-color: var(--ok-line); color: var(--ok); }
.pill.in_review::before, .pill.approved::before { background: none; border: 1.5px solid currentColor; }
.pill.published, .pill.ok, .badge.ok { background: var(--ok-bg); color: var(--ok); }
.pill.error, .badge.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn, .badge.warn { background: var(--warn-bg); color: var(--warn); }
.pill.missing { background: none; border: 1px dashed var(--line-2); color: var(--muted); }
.pill.missing::before { display: none; }
/* tags: comment types and learning outcomes. A tag's hue names its kind, nothing more */
.chip { display: inline-block; padding: 0 7px; border-radius: var(--r-sm); border: 1px solid transparent; background: var(--surface-2); color: var(--ink-2);
  font-size: var(--fs-xs); font-weight: 500; line-height: 18px; white-space: nowrap; vertical-align: middle; }
.chip::first-letter { text-transform: uppercase; }
.chip.good { background: var(--cat-strength-fill); color: var(--cat-strength); }
.chip.lang { background: var(--cat-language-fill); color: var(--cat-language); }
.chip.oc { background: none; border-color: var(--line-2); color: var(--ink-2); }
.demo-tag { background: var(--surface); border: 1px dashed var(--line-2); color: var(--muted); border-radius: var(--r-sm); padding: 1px 8px; font-size: var(--fs-xs); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--ctl); padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: 500 var(--fs-md)/1.2 var(--font); white-space: nowrap; cursor: pointer; text-decoration: none; position: relative;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast); -webkit-tap-highlight-color: transparent; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { background: var(--surface-3); }
.btn.pri { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.pri:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.pri:active { background: hsl(0 0% 28%); }
.btn.ok { background: var(--green-strong); border-color: var(--green-strong); color: #fff; }
.btn.ok:hover { background: var(--green-ink); border-color: var(--green-ink); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad-line); }
.btn.sm { min-height: var(--ctl-sm); padding: 0 9px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn:disabled, .btn.off, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover, .btn.off:hover { background: var(--surface); }
.btn.pri:disabled:hover { background: var(--primary); } .btn.ok:disabled:hover { background: var(--green-strong); }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--ink-2); animation: mk-spin 0.7s linear infinite; }
.btn.pri.is-loading::after, .btn.ok.is-loading::after { border-color: rgb(255 255 255 / 0.35); border-top-color: #fff; }
.ibtn { display: inline-grid; place-items: center; width: var(--ctl); height: var(--ctl); padding: 0; border: 1px solid transparent; border-radius: var(--r); background: none; color: var(--muted);
  cursor: pointer; flex: none; position: relative; transition: background var(--t-fast), color var(--t-fast); }
.ibtn:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.ibtn:active { background: var(--surface-3); }
.ibtn[aria-pressed="true"], .ibtn.on { background: var(--green-fill); color: var(--green-ink); }
.ibtn:disabled { opacity: 0.4; cursor: not-allowed; }
form.inline { display: inline; }

/* fields */
label { display: block; font-size: var(--fs-sm); font-weight: 500; margin: 0 0 4px; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; min-height: var(--ctl); border: 1px solid var(--line-2); border-radius: var(--r); padding: 5px 10px; background: var(--surface); color: var(--ink);
  transition: border-color var(--t-fast), box-shadow var(--t-fast); }
select { appearance: none; -webkit-appearance: none; padding-right: 28px; background-repeat: no-repeat; background-position: right 9px center; background-size: 10px 6px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
textarea { resize: vertical; line-height: var(--lh); min-height: 64px; }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: hsl(60 4% 66%); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px hsl(146 55% 40% / 0.18); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); border-color: var(--line); cursor: not-allowed; -webkit-text-fill-color: var(--muted); opacity: 1; }
input.bad, select.bad, textarea.bad, [aria-invalid="true"] { border-color: var(--bad); background: var(--bad-bg); }
input[type=checkbox], input[type=radio] { accent-color: var(--green); width: 16px; height: 16px; vertical-align: -3px; margin: 0 4px 0 0; }
input[type=file] { font-size: var(--fs-sm); max-width: 100%; color: var(--ink-2); }
input[type=file]::file-selector-button { margin-right: 10px; min-height: var(--ctl-sm); padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
  font: 500 var(--fs-sm)/1.2 var(--font); cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--surface-2); }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 120px; }
.row > div.fit { flex: 0 0 auto; min-width: 0; }
.field { margin-bottom: 10px; }
.help { font-size: var(--fs-xs); color: var(--muted); margin: 4px 0 0; }

/* messages: what happened (flash), what to know (note), and what to take care over (note warn) */
.flash, .note { padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r); font-size: var(--fs-sm); line-height: 1.45; }
.flash { margin-bottom: var(--sp-3); font-weight: 500; }
.flash.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--green-ink); }
.flash.err { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.note { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }
.note.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.note a, .flash a { text-decoration: underline; color: inherit; }
.note .btn, .flash .btn { text-decoration: none; margin-left: 6px; }
.empty { padding: var(--sp-8) var(--sp-4); text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }
.empty .btn { margin-top: var(--sp-3); }

/* tabs, filters, menus, tips, dialogs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs > button, .tabs > a { flex: none; padding: 8px 12px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-weight: 500;
  white-space: nowrap; cursor: pointer; transition: color var(--t-fast), border-color var(--t-fast); }
.tabs > button:hover, .tabs > a:hover { color: var(--ink); text-decoration: none; }
.tabs > [aria-selected="true"], .tabs > [aria-current="page"], .tabs > [aria-current="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: var(--sp-3); }
.filter { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--surface); color: var(--ink-2);
  font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.filter:hover { background: var(--surface-2); text-decoration: none; }
.filter[aria-pressed="true"], .filter[aria-current="true"] { background: var(--green-fill); border-color: var(--green-line); color: var(--green-ink); }
.filter .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.filter[aria-pressed="true"] .n { color: inherit; }
details { border-top: 1px solid var(--line); padding: 7px 0; }
details > summary { cursor: pointer; font-weight: 500; font-size: var(--fs-sm); color: var(--ink-2); }
details > summary:hover { color: var(--ink); }
details.menu { position: relative; display: inline-block; border: 0; padding: 0; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; z-index: 50; right: 0; top: calc(100% + 4px); min-width: 208px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-2); animation: mk-enter var(--t-enter) var(--ease-out) both; }
.menu-list a, .menu-list button { display: flex; width: 100%; align-items: center; gap: 8px; min-height: var(--ctl); padding: 0 10px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink);
  font: inherit; text-align: left; white-space: nowrap; cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: var(--surface-2); text-decoration: none; }
.menu-list hr { margin: 4px 0; }
[data-tip]:not(.nav-item)::after { content: attr(data-tip); content: attr(data-tip) / ""; position: absolute; z-index: 60; left: 50%; top: calc(100% + 6px); transform: translateX(-50%); padding: 4px 8px;
  border-radius: var(--r-sm); background: var(--ink); color: #fff; font: 500 var(--fs-xs)/1.3 var(--font); white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity var(--t-fast); }
[data-tip]:not(.nav-item):hover::after, [data-tip]:not(.nav-item):focus-visible::after { opacity: 1; transition-delay: 300ms; }
[data-tip][data-tip-at="top"]:not(.nav-item)::after { top: auto; bottom: calc(100% + 6px); }
[data-tip][data-tip-at="left"]:not(.nav-item)::after { left: auto; right: 0; transform: none; }
dialog.dialog { width: min(560px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3); }
dialog.dialog[open] { animation: mk-enter var(--t-enter) var(--ease-out) both; }
dialog::backdrop { background: hsl(60 10% 10% / 0.32); }
dialog.drawer { margin: 0 0 0 auto; width: min(440px, 100vw); height: 100vh; height: 100dvh; max-height: none; border-width: 0 0 0 1px; border-radius: 0; }
.dialog-h { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); }
.dialog-h h2 { margin: 0; }
.dialog-b { padding: var(--sp-4); }
.dialog-f { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--line); }

/* waiting, saving, arriving */
.spinner { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--ink-2); animation: mk-spin 0.7s linear infinite; vertical-align: -2px; flex: none; }
.skeleton { min-height: 12px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: mk-shimmer 1.4s linear infinite; }
.savestate { display: inline-flex; align-items: center; gap: 6px; min-height: 20px; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.savestate::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: none; }
.savestate[data-state="saving"]::before { width: 10px; height: 10px; background: none; border: 2px solid var(--line-2); border-top-color: var(--ink-2); animation: mk-spin 0.7s linear infinite; }
.savestate[data-state="saved"]::before { background: var(--green); }
.savestate[data-state="error"] { color: var(--bad); }
.savestate[data-state="error"]::before { background: var(--bad); }
.enter { animation: mk-enter var(--t-enter) var(--ease-out) both; }
@keyframes mk-spin { to { transform: rotate(360deg); } }
@keyframes mk-shimmer { to { background-position: -200% 0; } }
@keyframes mk-enter { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  /* work still shows as work, without movement: a still ring in place of a turning one, and nothing slides */
  .mkly *, .mkly *::before, .mkly *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .spinner, .btn.is-loading::after, .savestate[data-state="saving"]::before { animation: none !important; border-style: dotted; border-color: var(--ink-2); }
}
kbd { display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); font: 600 var(--fs-2xs)/1.6 var(--mono); text-align: center; }

/* ------------------------------------------------------------------ figures: bars in one quiet colour */
.bar { height: 6px; background: var(--data-track); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--data); border-radius: 3px; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-top: 8px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.bars .col i { display: block; width: 100%; background: var(--data); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars .col b { font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; } .bars .col span { font-size: var(--fs-2xs); color: var(--muted); white-space: nowrap; }
.hbar { display: grid; grid-template-columns: 150px 1fr 118px; gap: 10px; align-items: center; padding: 4px 0; font-size: var(--fs-sm); }
.hbar > span:first-child::first-letter { text-transform: uppercase; }
.hbar > span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* how far a set of scripts has come, one segment for each state, in lifecycle order */
.seg { display: flex; height: 6px; min-width: 96px; border-radius: 3px; overflow: hidden; background: var(--data-track); }
.seg > i { display: block; height: 100%; min-width: 2px; }
.seg > .s-published { background: var(--green); } .seg > .s-approved { background: var(--green-line); } .seg > .s-review { background: var(--info); }
.seg > .s-running { background: var(--data-soft); } .seg > .s-error { background: var(--bad); }
.legend { display: flex; gap: 4px 12px; font-size: var(--fs-xs); color: var(--muted); align-items: center; flex-wrap: wrap; }
.legend span { white-space: nowrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; border-bottom: 2px solid; }
.legend .k-published { background: var(--green); border: 0; } .legend .k-approved { background: var(--green-line); border: 0; } .legend .k-review { background: var(--info); border: 0; }
.legend .k-running { background: var(--data-soft); border: 0; } .legend .k-error { background: var(--bad); border: 0; }
.diff-b { color: var(--bad); text-decoration: line-through; } .diff-a { color: var(--ok); }

/* ------------------------------------------------------------------ small pieces several screens share */
a.pill:hover { text-decoration: none; filter: brightness(0.96); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); font-size: var(--fs-sm); margin-top: 6px; }
.pre.clip { max-height: 220px; overflow: auto; }
p.acts, div.acts.row-acts { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-3) 0 0; }
.card-f { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--line); align-items: center; }
.up { color: var(--ok); } .down { color: var(--bad); }
.cap { display: inline-block; } .cap::first-letter { text-transform: uppercase; }
table.kvt td:first-child { color: var(--ink-2); }
table.kvt td:last-child { white-space: nowrap; }
td.bands .chip { margin: 1px 0; }
.setup [id], .wrap > [id] { scroll-margin-top: 64px; }
/* a plain list of things with an action at the end of each row */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); padding: 10px 0; border-top: 1px solid var(--line); }
.rows > li:first-child { border-top: 0; padding-top: 0; }
.rows .main { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
td.bands { min-width: 150px; }
h2.sec { margin: var(--sp-5) 0 var(--sp-2); font-size: var(--fs-md); color: var(--ink-2); }
h2.sec:first-of-type { margin-top: 0; }
/* the student's list of marked work: one tappable card for each piece */
.work { display: grid; gap: var(--sp-2); }
.work-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: var(--sp-2) var(--sp-5); align-items: center; margin: 0; color: var(--ink); transition: border-color var(--t-fast), background var(--t-fast); }
.work-item:hover { text-decoration: none; border-color: var(--line-2); background: hsl(60 10% 98.5%); }
.work-what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.work-what b { font-weight: 600; overflow-wrap: anywhere; }
.work-mark { white-space: nowrap; font-variant-numeric: tabular-nums; }
.work-mark b { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.02em; }
.work-go { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; }
.work-item:hover .work-go { color: var(--ink); }
@media (max-width: 760px) {
  .work-item { grid-template-columns: minmax(0, 1fr) auto; }
  .work-go { grid-column: 1 / -1; padding-top: var(--sp-2); border-top: 1px solid var(--line); justify-content: space-between; min-height: 32px; }
}

/* ------------------------------------------------------------------ sign in */
.login { max-width: 384px; margin: 10vh auto 0; }
.login .card { padding: var(--sp-6); }
.login .brand { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.login .brand b { display: block; font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.login .brand small { color: var(--muted); font-size: var(--fs-xs); }
.login h1 { font-size: var(--fs-xl); margin-bottom: 2px; }
.login .btn { width: 100%; margin-top: var(--sp-1); }
.login .foot { margin: var(--sp-4) 0 0; text-align: center; }

/* ------------------------------------------------------------------ a script as text, marks, criteria and comment cards
   (the workspace, the printable report, the cohort gallery and the panels all draw on these) */
.script { padding: 14px 16px; font-size: var(--fs-md); line-height: 1.85; }
.script.zh { font-size: var(--fs-lg); line-height: 2.05; }
.script .p { margin: 0 0 12px; position: relative; padding-left: 26px; }
.script .p > .n { position: absolute; left: 0; top: 3px; font-size: var(--fs-2xs); color: var(--faint); font-weight: 600; font-variant-numeric: tabular-nums; }
.script .pn { margin: -6px 0 14px 26px; font-size: var(--fs-sm); color: var(--ink-2); background: var(--surface-2); border-left: 2px solid var(--line-2); padding: 5px 9px; border-radius: 0 var(--r-sm) var(--r-sm) 0; line-height: 1.5; }
mark { background: var(--cat-content-fill); border-bottom: 2px solid var(--cat-content); padding: 1px 0; border-radius: 2px; color: inherit; }
.marks { padding: 12px; border-bottom: 1px solid var(--line); }
.mk { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 6px 0; }
.mk .ai { font-size: var(--fs-sm); color: var(--muted); text-align: right; }
.mk input { width: 62px; text-align: center; font-weight: 600; font-size: var(--fs-lg); padding: 4px; }
.mk .of { color: var(--muted); }
.mk.changed input { border-color: var(--info-line); background: var(--info-bg); }
.total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-weight: 600; }
.total b { font-size: var(--fs-2xl); font-variant-numeric: tabular-nums; }
.crit { font-size: var(--fs-sm); padding: 5px 0; border-bottom: 1px dashed var(--line); }
.crit:last-child { border: 0; }
.crit q { color: var(--muted); font-style: italic; }
.cm { border-bottom: 1px solid var(--line); padding: 9px 12px; }
.cm .meta { display: flex; gap: 6px; align-items: center; margin-bottom: 3px; font-size: var(--fs-xs); color: var(--muted); flex-wrap: wrap; }
.cm .quote { font-size: var(--fs-sm); color: var(--muted); border-left: 2px solid var(--line-2); padding-left: 7px; margin: 3px 0 4px; }
.cm .txt { font-size: var(--fs-sm); }
.logline { font-size: var(--fs-sm); padding: 4px 12px; border-bottom: 1px solid var(--line); }
.logline .w { color: var(--muted); }
.keys { padding: 6px 0; line-height: 2.1; color: var(--ink-2); }
.noteinput { position: absolute; z-index: 5; width: 190px; font-size: var(--fs-sm); padding: 3px 6px; border: 1.5px solid #d92d20; border-radius: var(--r-sm); min-height: 0; }

/* the three parts of a student's feedback */
h3.fp { margin: 14px 0 4px; } h3.fp.good { color: var(--cat-strength); } h3.fp.work { color: var(--ink); } h3.fp.next { color: var(--info); }
.fpl { margin: 0; padding-left: 18px; } .fpl li { margin-bottom: 3px; }

/* structured papers: the table of questions and marking points */
table.paper td { vertical-align: top; padding: 7px 8px; }
table.paper textarea { min-height: 54px; }

/* ------------------------------------------------------------------ smaller screens and touch */
@media (max-width: 1099px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  /* The navigation leaves the side: a bar across the top, with the menu in a drawer (staff) or tabs along the bottom (students). */
  body.app { display: block; }
  .topbar { display: flex; align-items: center; gap: var(--sp-2); position: sticky; top: 0; z-index: 30; min-height: 52px; padding: 0 var(--sp-3); background: var(--bg); border-bottom: 1px solid var(--line); }
  .topbar .logo { flex: 1; font-size: var(--fs-lg); }
  .nav { position: fixed; inset: 0 auto 0 0; z-index: 70; width: min(288px, 86vw); padding: var(--sp-3) var(--sp-2); box-shadow: var(--shadow-3); transform: translateX(-102%); visibility: hidden;
    transition: transform var(--t-pane) var(--ease-inout), visibility 0s linear var(--t-pane); align-items: stretch; }
  .mkly.nav-open .nav { transform: none; visibility: visible; transition: transform var(--t-pane) var(--ease-inout); }
  .mkly.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 65; background: hsl(60 10% 10% / 0.32); }
  .nav .nav-toggle { display: none; }
  .nav-item { min-height: var(--ctl-touch); }
  /* in the drawer the menu is always full width, whatever was chosen on a wide screen */
  .nav-rail .nav { align-items: stretch; padding: var(--sp-3) var(--sp-2); }
  .nav-rail .nav-top { flex-direction: row; padding: 0 var(--sp-1) 0 var(--sp-2); }
  .nav-rail .nav-label, .nav-rail .nav-grp { position: static; width: auto; height: auto; clip-path: none; opacity: 1; }
  .nav-rail .nav-grp { padding: var(--sp-4) 12px var(--sp-1); }
  .nav-rail .nav nav { align-items: stretch; }
  .nav-rail .nav-item { width: auto; padding: 0 12px; justify-content: flex-start; min-height: var(--ctl-touch); }
  .nav-rail .nav-item::after { display: none; }
  .nav-rail .nav-user { flex-direction: row; width: auto; padding: var(--sp-3) var(--sp-1) 0 var(--sp-2); }
  .is-student .topbar [data-nav-open] { display: none; }
  .is-student .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; color: var(--muted); font-size: var(--fs-2xs); font-weight: 500; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a[aria-current="page"] { color: var(--ink); }
  .tabbar a[aria-current="page"] .ic { color: var(--green); }
  .is-student .wrap { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  .wrap { padding: var(--sp-4) var(--sp-4) var(--sp-12); }
  .wrap.wide { padding: var(--sp-2); }
}
@media (max-width: 760px) {
  .wrap { padding: var(--sp-4) var(--sp-3) var(--sp-12); }
  .head { align-items: flex-start; }
  .g2, .g3, .g-main { grid-template-columns: minmax(0, 1fr); }
  .fb > :first-child { order: 2; }   /* student feedback page: marks and the teacher's feedback come before the script */
  .card { overflow-x: auto; }   /* a wide table scrolls inside its card, not the whole page */
  .hbar { grid-template-columns: 104px 1fr auto; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* a table marked stack turns each row into a block, so nothing a teacher needs sits off the edge of a phone */
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; }
  table.stack tr.hd { display: none; }
  table.stack tr { padding: var(--sp-3); border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { padding: 3px 0; border: 0; text-align: left; white-space: normal; }
  table.stack td.num { text-align: left; }
  table.stack td[data-th]::before { content: attr(data-th) ": "; color: var(--muted); }
  table.stack td:empty { display: none; }
  table.stack td.right { text-align: left; padding-top: var(--sp-2); }
  th, td { padding-left: var(--sp-2); padding-right: var(--sp-2); }
}
@media (pointer: coarse) {
  /* 16 px inputs stop iOS zooming the page when a field is tapped */
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], select, textarea { font-size: 16px; }
  .mk input { width: 74px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
}

/* ------------------------------------------------------------------ print: the page, not the application around it */
@media print {
  .nav, .topbar, .tabbar, .nav-scrim, .skip, .noprint { display: none !important; }
  html.mkly, body { background: #fff; }
  body.app { display: block; }
  .wrap { max-width: none; padding: 0; }
}
