/* Silsila unified UI: components and layouts (direction B, "Reading desk").
   Logical properties throughout: the same rules serve English and Arabic.
   Phone layout below 860 px: bottom bar, sheets, lists instead of tables. */

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--ivory); -webkit-text-size-adjust: 100%; scroll-padding-block: 16px 96px; }
html:has(.toasts) { scroll-padding-bottom: 120px; }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font-body); font-size: var(--fs-2); line-height: var(--lh);
  color: var(--ink); background: var(--ivory);
  -webkit-font-smoothing: antialiased;
}
h1, h2 { font-family: var(--font-display); font-weight: 600; margin: 0; text-wrap: balance; }
h1 { font-size: var(--fs-5); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-4); line-height: var(--lh-tight); }
html[lang="en"] h1, html[lang="en"] h2 { letter-spacing: -.015em; }
html[lang="ar"] h1, html[lang="ar"] h2 { font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }
b { font-weight: 600; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.sprite { position: absolute; }
.skip {
  position: absolute; inset-inline-start: 12px; top: -80px; z-index: 100;
  padding: 10px 16px; border-radius: var(--r-sm); background: var(--gold); color: var(--ink);
}
.skip:focus { top: 12px; }
.ico {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
[dir="rtl"] .ico-dir { transform: scaleX(-1); }          /* directional icons mirror */
.ico-back { transform: scaleX(-1); }
[dir="rtl"] .ico-back { transform: none; }

/* ---- Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r); border: 1px solid transparent;
  font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(46, 36, 24, .18); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: var(--surface); border-color: var(--field-line); color: var(--accent-deep); }
.btn-outline:hover { background: var(--sand); border-color: var(--accent); }
.btn-soft { background: var(--sand); border-color: var(--line-strong); color: var(--accent-deep); }
.btn-soft:hover { background: var(--sand-deep); border-color: var(--field-line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-on-dark { border-color: rgba(246, 238, 221, .45); color: var(--on-dark); }
.btn-on-dark:hover { background: rgba(246, 238, 221, .1); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 14px; }
.btn:active { transform: translateY(1px); }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink-soft); cursor: pointer;
  transition: background-color .15s;
}
.icon-btn:hover { background: var(--sand); color: var(--ink); }

/* ---- Tags: a colour, a shape and a word --------------------------------------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  font-size: var(--fs-1); font-weight: 500; line-height: 1.5; white-space: nowrap;
  background: var(--surface); color: var(--ink-soft);
}
.tag::before { content: ""; width: 7px; height: 7px; flex: none; }
.tag-plain::before, .tag-due::before, .tag-overdue::before { display: none; }
.tag-public   { background: var(--public-bg);   color: var(--public-fg);   border-color: var(--public-line); }
.tag-public::before   { border-radius: 50%; background: currentColor; }
.tag-students { background: var(--students-bg); color: var(--students-fg); border-color: var(--students-line); }
.tag-students::before { border-radius: 50%; border: 1.5px solid currentColor; }
.tag-staff    { background: var(--staff-bg);    color: var(--staff-fg);    border-color: var(--staff-line); }
.tag-staff::before    { border-radius: 1.5px; background: currentColor; }
.tag-restricted { background: var(--restricted-bg); color: var(--restricted-fg); border-color: var(--restricted-line); }
.tag-restricted::before { transform: rotate(45deg); border-radius: 1px; background: currentColor; }
.tag-due      { background: var(--due-bg);      color: var(--due-fg);      border-color: var(--due-line); }
.tag-overdue  { background: var(--danger-bg);   color: var(--danger);      border-color: var(--danger-line); }

/* ---- Forms -------------------------------------------------------------------- */
.field { display: grid; gap: 6px; }
.field label, .choices legend { font-weight: 500; }
.hint { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="search"], input[type="email"], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 14px; color: var(--ink);     /* never the colour of a dark banner around it */
  border: 1px solid var(--field-line); border-radius: var(--r); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
textarea { display: block; resize: vertical; line-height: var(--lh); }
input::placeholder { color: var(--muted); opacity: 1; }
input[type="text"]:focus, input[type="search"]:focus, input[type="email"]:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(122, 90, 46, .22);
}
input[type="radio"] { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }

/* Choice cards: a radio button, a title and what it does. */
.choices { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.choices legend { margin-bottom: 8px; padding: 0; }
.choice {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); cursor: pointer;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.choice:hover { border-color: var(--field-line); }
.choice:has(input:checked) { border-color: var(--accent); background: #fff; box-shadow: inset 0 0 0 1px var(--accent); }
.choice:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.choice input:focus-visible { outline: none; }
.choice-body { display: grid; gap: 2px; flex: 1; min-width: 0; }
.choice-title { font-weight: 600; }
.choice-text { font-size: var(--fs-1); color: var(--ink-soft); }
.choice-side { font-size: var(--fs-1); color: var(--muted); white-space: nowrap; }
.choice-extra { display: none; margin-top: 8px; }
.choice:has(input:checked) .choice-extra { display: block; }
.choice-danger:has(input:checked) { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.choice-danger input { accent-color: var(--danger); }

.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid; border-radius: var(--r); }
.alert .ico { margin-top: 1px; }
.alert-error { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.alert-warn { background: var(--due-bg); border-color: var(--due-line); color: var(--ink); }
.alert-warn .ico { color: var(--due-fg); }
.alert p + p { margin-top: 4px; }
.quote { color: var(--ink-soft); }

/* ---- Shell: the ink frame ------------------------------------------------------ */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 24px; padding: 28px 16px 24px;
  background: var(--ink); color: var(--on-dark);
}
.side :focus-visible, .tabbar :focus-visible, .pub-head :focus-visible, .signin-brand :focus-visible { outline-color: var(--gold); }
.logo { align-self: flex-start; margin-inline-start: 12px; border-radius: 6px; }
.logo img { display: block; height: 48px; width: auto; }
.side ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.side ul + ul { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(246, 238, 221, .16); }
.side ul:empty { display: none; }
.side nav a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
  border-radius: var(--r-sm); color: var(--on-dark-soft); text-decoration: none;
  transition: background-color .15s, color .15s;
}
.side nav a .ico { width: 20px; height: 20px; opacity: .85; }
.side nav a:hover { background: rgba(246, 238, 221, .08); color: var(--on-dark); }
.side nav a[aria-current] { background: rgba(235, 191, 94, .14); color: var(--gold); font-weight: 600; }
.side nav a[aria-current] .ico { opacity: 1; }
.count {
  margin-inline-start: auto; min-width: 28px; padding: 1px 8px; border-radius: var(--r-pill);
  font-size: var(--fs-1); font-weight: 700; line-height: 1.5; text-align: center; background: var(--gold); color: var(--ink);
}
.partner {
  display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 16px 12px 0;
  border-top: 1px solid rgba(246, 238, 221, .16); font-size: var(--fs-1); color: var(--on-dark-soft);
}
.partner img { height: 32px; width: auto; flex: none; }

.main { width: 100%; max-width: 1280px; padding: 24px 40px 64px; }
main { margin-top: 32px; }

/* ---- Top bar: search, language, account ----------------------------------------- */
.topbar { display: flex; align-items: center; gap: 12px; }
.topbar-logo { display: none; border-radius: 9px; }
.topbar-logo img { display: block; width: 40px; height: 40px; border-radius: 9px; }
.search { position: relative; flex: 1 1 280px; max-width: 560px; }
.search-phone { display: none; }      /* phones: the same form, placed after the language switch */
.search .ico { position: absolute; inset-inline-start: 14px; top: 50%; margin-top: -11px; color: var(--muted); pointer-events: none; }
.search input { padding-block: 0; padding-inline: 46px 16px; }
.lang {
  margin-inline-start: auto; display: inline-flex; flex: none; padding: 2px;
  border: 1px solid var(--field-line); border-radius: var(--r-pill); background: var(--surface);
}
.lang a {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: var(--r-pill);
  font-size: var(--fs-1); font-weight: 500; line-height: 1.2; text-decoration: none; color: var(--ink-soft);
  transition: background-color .15s, color .15s;
}
.lang a:hover { color: var(--ink); }
.lang a[aria-current] { background: var(--accent); color: #fff; }

/* Menus that open from a button (<details>): the account menu, the phone's "More". */
.menu { position: relative; flex: none; }
.menu > summary, .tab-more > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker, .tab-more > summary::-webkit-details-marker { display: none; }
.account {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--ink); color: #F3E3BF; font-size: var(--fs-1); font-weight: 500;
  transition: box-shadow .15s;
}
.account:hover, .menu[open] > .account { box-shadow: 0 0 0 3px rgba(122, 90, 46, .28); }
.menu-panel {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); z-index: 30; width: 272px; padding: 8px;
  border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-lg);
}
.menu-who { display: grid; gap: 2px; margin-bottom: 6px; padding: 8px 12px 12px; border-bottom: 1px solid var(--line); }
.menu-who span { font-size: var(--fs-1); color: var(--ink-soft); }
.menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: var(--r); background: none; color: var(--ink); text-align: start; text-decoration: none; cursor: pointer;
  transition: background-color .15s;
}
.menu-item:hover { background: var(--sand); }
.menu-item[aria-current] { font-weight: 600; background: var(--sand); }
.menu-item .ico { color: var(--bronze); }

/* ---- Page head -------------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; }
.eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; font-size: var(--fs-1); font-weight: 500; color: var(--accent); }
html[lang="en"] .eyebrow > span:first-child { text-transform: uppercase; letter-spacing: .07em; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.crumb { margin-bottom: 12px; }
.crumb a { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; font-weight: 500; text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.crumb .ico { width: 18px; height: 18px; }
.sec-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 20px; }
.lead { margin-top: 4px; color: var(--ink-soft); }
.more-link { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.more-link:hover { text-decoration: underline; }
.more-link .ico { width: 18px; height: 18px; }
.foot-note { font-size: var(--fs-1); color: var(--muted); }
.date { white-space: nowrap; }

/* ---- Panels ------------------------------------------------------------------------- */
.panel { padding: 24px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); }
.panel-wide, .panel-narrow { margin-top: 28px; }
.panel-narrow { max-width: 640px; }
.desk { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; margin-top: 28px; }
.desk-side { display: grid; gap: 24px; }

/* Items waiting for a retention decision. */
.decision-list { list-style: none; margin: 20px 0 0; padding: 0; }
.decision-list li {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto auto; gap: 8px 16px; align-items: center;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.thumb { display: block; width: 64px; height: 48px; flex: none; border-radius: var(--r-sm); background: var(--sand); object-fit: cover; }
.d-title { font-weight: 600; }
.d-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 2px; font-size: var(--fs-1); color: var(--ink-soft); }
.d-date { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 116px; font-size: var(--fs-1); color: var(--ink-soft); }
.decisions .foot-note { padding-top: 14px; border-top: 1px solid var(--line); }
.panel-wide .decision-list { margin-top: 12px; }

.glance { padding: 24px; border-radius: var(--r-lg); background: var(--sand); }
.glance dl { margin: 12px 0 0; }
.glance dl > div { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line-strong); }
.glance dl > div:last-child { padding-bottom: 0; }
.glance dt .note { display: block; font-size: var(--fs-1); color: var(--ink-soft); }
.glance dd { margin: 0; font-family: var(--font-display); font-size: var(--fs-4); font-weight: 600; line-height: 1.2; font-variant-numeric: lining-nums; }

.activity-list { list-style: none; margin: 8px 0 0; padding: 0; }
.activity-list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.activity-list .meta { font-size: var(--fs-1); color: var(--muted); }
.more-row { margin-top: 4px; margin-bottom: -12px; }

/* ---- Empty and error states ------------------------------------------------------------ */
.empty { display: grid; justify-items: center; gap: 8px; max-width: 460px; margin: 64px auto; text-align: center; color: var(--ink-soft); }
.empty > .ico { width: 56px; height: 56px; padding: 14px; border-radius: 50%; background: var(--sand); color: var(--bronze); }
.empty-title { font-family: var(--font-display); font-size: var(--fs-3); font-weight: 600; line-height: var(--lh-tight); color: var(--ink); }
.empty .btn { margin-top: 12px; }
.empty-inline { margin: 32px auto 16px; }

/* ---- Dialog (a sheet on phones) ----------------------------------------------------------- */
.dialog {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; overflow: auto;
  border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(46, 36, 24, .5); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 12px 0 24px; }
[dir="rtl"] .dialog-head { padding: 16px 24px 0 12px; }
.dialog-head h2 { font-size: var(--fs-3); }
.decide { display: grid; gap: 18px; }
.dialog .decide { padding: 12px 24px 0; }
.decide-item { display: flex; gap: 14px; align-items: flex-start; padding: 12px; border-radius: var(--r); background: var(--sand); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 12px; }
.dialog .dialog-actions {
  position: sticky; bottom: 0; margin-inline: -24px; padding: 14px 24px 20px;
  border-top: 1px solid var(--line); background: var(--surface);
}

/* ---- Toast: says what happened, and offers the undo ---------------------------------------- */
.toasts { position: fixed; inset-inline: 16px; bottom: 24px; z-index: 50; display: grid; justify-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 12px; max-width: 620px; padding: 10px 10px 10px 16px;
  border-radius: var(--r-lg); background: var(--ink); color: var(--on-dark); box-shadow: var(--shadow-lg);
  pointer-events: auto; animation: rise .25s ease both;
}
[dir="rtl"] .toast { padding: 10px 16px 10px 10px; }
.toast > .ico { color: var(--gold); }
.toast p { flex: 1; min-width: 0; }
.toast-action {
  min-height: 44px; padding: 0 16px; border: 1px solid rgba(246, 238, 221, .45); border-radius: var(--r);
  background: transparent; color: var(--gold); font-weight: 600; cursor: pointer; transition: background-color .15s;
}
.toast-action:hover { background: rgba(246, 238, 221, .1); }
.toast-close { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; color: var(--on-dark-soft); }
.toast-close:hover { background: rgba(246, 238, 221, .1); color: var(--on-dark); }
.toast :focus-visible { outline-color: var(--gold); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---- Sign-in ---------------------------------------------------------------------------------- */
.signin-shell { display: grid; grid-template-columns: minmax(320px, 2fr) 3fr; min-height: 100vh; }
.signin-brand {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 48px 32px;
  background: var(--ink); color: var(--on-dark); text-align: center;
}
.signin-brand > img { width: 220px; height: auto; }
.signin-tagline { font-family: var(--font-display); font-size: var(--fs-3); color: var(--gold); }
.signin-partner { display: flex; align-items: center; gap: 10px; margin-top: 24px; font-size: var(--fs-1); color: var(--on-dark-soft); }
.signin-main { display: flex; flex-direction: column; margin: 0; padding: 24px 40px 48px; }
.signin-top { display: flex; }
.signin-form { display: grid; gap: 16px; width: 100%; max-width: 480px; margin: auto; padding-block: 24px; }
.signin-form .eyebrow { margin-bottom: -8px; }
.signin-form .lead { margin-top: -8px; }

/* ---- Public pages (anonymous) -------------------------------------------------------------------- */
.pub-head { display: flex; align-items: center; gap: 12px; padding: 14px 32px; background: var(--ink); color: var(--on-dark); }
.pub-head .logo { margin: 0; }
.pub-head .lang { border-color: rgba(246, 238, 221, .4); background: transparent; }
.pub-head .lang a { color: var(--on-dark-soft); }
.pub-head .lang a[aria-current] { background: var(--gold); color: var(--ink); }
.pub-main { max-width: 1280px; margin: 0 auto; padding: 32px 32px 64px; }
.pub-foot { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 20px 16px; border-top: 1px solid var(--line); font-size: var(--fs-1); color: var(--ink-soft); }
.public .page-head .eyebrow { justify-content: flex-start; }

/* ---- Checkpoint 2 components ------------------------------------------------------------------------ */
.h-sub { margin: 0 0 10px; font-family: var(--font-body); font-size: var(--fs-2); font-weight: 600; letter-spacing: 0; }
.panel > .h-sub:not(:first-child), .panel > h3.h-sub { margin-top: 20px; }
.panel + .panel, .item-body > * + *, .policy-main > * + * { margin-top: 20px; }
.panel-list { margin-top: 20px; }
.panel-list > h2 { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; font-size: var(--fs-3); }
.count-plain { font-family: var(--font-body); font-size: var(--fs-1); font-weight: 500; color: var(--muted); }
.meta { font-size: var(--fs-1); color: var(--muted); }
.hint { font-size: var(--fs-1); }
.title-other { margin-top: 4px; font-family: var(--font-display); font-size: var(--fs-3); color: var(--ink-soft); }
.ico-inline { width: 16px; height: 16px; vertical-align: -3px; }
.tag-status { border-radius: 6px; }
.tag-status::before, .tag-noshape::before { display: none; }
.tag-in_review { background: var(--due-bg); color: var(--due-fg); border-color: var(--due-line); }
.tag-sent_back { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.tag-published { background: var(--public-bg); color: var(--public-fg); border-color: var(--public-line); }
.actions-center { justify-content: center; margin-top: 16px; }

input[type="date"] { width: 100%; min-height: 44px; padding: 8px 14px; color: var(--ink); border: 1px solid var(--field-line); border-radius: var(--r); background: #fff; }
input[type="date"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(122, 90, 46, .22); }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.field-error { font-size: var(--fs-1); font-weight: 500; color: var(--danger); }
.error-list { margin: 4px 0 0; padding-inline-start: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-stack { display: grid; gap: 18px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.field-grow { flex: 1 1 200px; }
.choices-row { display: flex; flex-wrap: wrap; }
.choices-row legend { float: none; width: 100%; }
.choice-compact { align-items: center; padding: 0 14px; min-height: 44px; }
.choice-compact input { margin: 0; }
.choice-compact .choice-title { font-weight: 500; }
.note-box { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r); background: var(--sand); color: var(--ink-soft); font-size: var(--fs-1); }
.note-box .ico { width: 18px; height: 18px; color: var(--bronze); }
.disclosure { margin-top: 12px; }
.disclosure > summary { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-weight: 500; cursor: pointer; }
.disclosure[open] > summary { margin-bottom: 8px; }

/* file pickers: the native control, dressed */
.pickers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-width: 0; margin: 0; padding: 0; border: 0; }
.pickers legend { margin-bottom: 8px; padding: 0; font-weight: 500; }
.pickers .hint { grid-column: 1 / -1; }
.picker { display: grid; gap: 8px; align-content: start; padding: 14px; border: 1.5px dashed var(--field-line); border-radius: var(--r); background: var(--surface); cursor: pointer; transition: border-color .15s, background-color .15s; }
.picker:hover, .picker:focus-within { border-color: var(--accent); background: #fff; }
.picker-title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--accent-deep); }
.picker input[type="file"] { width: 100%; min-width: 0; font-size: var(--fs-1); color: var(--ink-soft); }
.picker input[type="file"]::file-selector-button { display: none; }

/* facts: label and value pairs */
.facts { display: grid; gap: 0; margin: 0; }
.facts > div { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.facts > div:first-child { border-top: 0; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; }
.facts-tight > div { grid-template-columns: 1fr auto; padding: 8px 0; }
.facts-stack > div { grid-template-columns: 1fr; gap: 2px; }
.facts-stack dt { font-size: var(--fs-1); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 2px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--ivory); }
.chip .ico { width: 16px; height: 16px; color: var(--bronze); }
.chip-kind { font-size: var(--fs-1); color: var(--muted); }
.chip:has(.chip-remove) { padding-inline-end: 0; }
.chip-remove { display: grid; place-items: center; width: 44px; height: 44px; margin-block: -4px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink-soft); cursor: pointer; }
.chip-remove:hover { color: var(--danger); background: var(--danger-bg); }
.chip-remove .ico { width: 16px; height: 16px; color: inherit; }
.links-panel > * + * { margin-top: 12px; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-list li { padding: 10px 14px; border-inline-start: 3px solid var(--line-strong); background: var(--ivory); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
[dir="rtl"] .comment-list li { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.comment-list li + li { margin-top: 8px; }

/* collections */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin: 28px 0 0; padding: 0; list-style: none; }
.card-grid .panel { margin: 0; }
.coll-card { display: flex; flex-direction: column; gap: 8px; transition: box-shadow .15s, border-color .15s; }
.coll-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lg); }
.coll-card h2 { font-size: var(--fs-3); }
.coll-card h2 a { color: var(--ink); text-decoration: none; }
.coll-card h2 a:hover { color: var(--accent-deep); text-decoration: underline; }
.coll-about { flex: 1; color: var(--ink-soft); }

/* filters and item rows */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 24px; }
.filters .field { flex: 0 1 180px; }
.filters .field-grow { flex: 1 1 260px; }
.filters label { font-size: var(--fs-1); color: var(--ink-soft); }
.js .filters-go { display: none; }
.js .no-js-only { display: none; }
.result-count { font-size: var(--fs-1); color: var(--ink-soft); }
.item-rows, .work-list { list-style: none; margin: 8px 0 0; padding: 0; }
.item-rows li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto 130px; gap: 6px 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.work-list li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 6px 16px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
.r-title { font-weight: 600; color: var(--ink); text-decoration: none; }
.r-title:hover { color: var(--accent-deep); text-decoration: underline; }
.r-tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.r-date { font-size: var(--fs-1); color: var(--ink-soft); text-align: end; }
.cell-label { display: none; }
.work-comment { display: flex; gap: 8px; margin-top: 8px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--due-bg); }
.work-comment .ico { width: 18px; height: 18px; margin-top: 2px; color: var(--due-fg); }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); font-size: var(--fs-1); color: var(--ink-soft); }

/* item page and describe */
.item-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 24px; }
.item-layout .panel { margin-top: 0; }
.item-body > * + * { margin-top: 20px !important; }
.item-media { display: grid; gap: 12px; }
.item-image { display: block; width: 100%; height: auto; border-radius: var(--r); background: var(--sand); }
.item-desc { margin-bottom: 12px; }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: grid; gap: 0; padding: 6px 0; border-top: 1px solid var(--line); }
.file-list a { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; overflow-wrap: anywhere; }
.access { background: var(--sand); border-color: var(--line-strong); box-shadow: none; }
.access .facts > div { border-color: var(--line-strong); }
.access > * + * { margin-top: 14px; }
.alert + .item-layout, .alert + .alert { margin-top: 16px; }
main > .alert { margin-top: 20px; }

/* the action bar: at the end of the form on desktop, fixed above the bottom bar on phones */
.actionbar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.actionbar-note { margin-inline-end: auto; font-size: var(--fs-1); color: var(--muted); }
.actionbar form { display: contents; }

/* review */
.review { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 24px; }
.review .panel { margin-top: 0; }
.queue { padding: 8px; }
.queue ul { list-style: none; margin: 0; padding: 0; }
.queue a { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border: 1px solid transparent; border-radius: var(--r); color: var(--ink); text-decoration: none; transition: background-color .15s; }
.queue a:hover { background: var(--sand); }
.queue a[aria-current] { background: var(--sand); border-color: var(--bronze); }
.q-text { display: grid; gap: 2px; justify-items: start; min-width: 0; }
.detail > * + * { margin-top: 18px; }
.detail-top { display: flex; flex-wrap: wrap; gap: 20px; }
.detail-image { width: 220px; height: 165px; flex: none; border-radius: var(--r); object-fit: cover; background: var(--sand); }
.detail-top > div { flex: 1 1 260px; display: grid; gap: 6px; align-content: start; }
.checklist { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0; padding: 14px 16px; border-radius: var(--r); background: var(--sand); list-style: none; }
.checklist li { display: flex; align-items: center; gap: 6px; font-size: var(--fs-1); font-weight: 500; }
.checklist .ico { width: 18px; height: 18px; }
.checklist .is-ok { color: var(--ok); }
.checklist .is-missing { color: var(--danger); }
.checklist .is-optional { color: var(--due-fg); }
.review-form { display: grid; gap: 12px; }
.review-items { list-style: none; margin: 8px 0 0; padding: 0; }
.review-items > li { padding: 16px 0; border-top: 1px solid var(--line); }
.review-title { font-size: var(--fs-3); }
.review-texts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 24px; margin: 12px 0; }
.review-texts dt { font-size: var(--fs-1); color: var(--ink-soft); }
.review-texts dd { margin: 0; white-space: pre-line; }
.review-missing { color: var(--danger); }
.review-actions { display: grid; gap: 12px; margin-top: 12px; }
/* B8-6: a change to a public item, before / after per field */
.change-list { display: grid; gap: 12px; margin: 12px 0; }
.change-list dt { font-size: var(--fs-1); color: var(--ink-soft); }
.change-list dd { margin: 0; white-space: pre-line; }
.change-label { font-size: var(--fs-1); color: var(--ink-soft); }
.change-after { font-weight: 600; }
.change-reason { margin-top: 8px; }
.btn:disabled { background: var(--sand-deep); color: var(--muted); box-shadow: none; cursor: not-allowed; }
.crumb-phone { display: none; }

/* add and import */
.add-layout { display: grid; grid-template-columns: minmax(0, 640px) minmax(0, 320px); gap: 24px; align-items: start; margin-top: 24px; }
.add-layout .panel { margin-top: 0; }
.import-card { display: grid; gap: 10px; justify-items: start; background: var(--sand); box-shadow: none; }
.import-card > .ico { width: 28px; height: 28px; color: var(--bronze); }
.steps { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 24px 0 0; padding: 0; list-style: none; }
.steps li { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); }
.step-dot { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); font-size: var(--fs-1); font-weight: 700; }
.step-dot .ico { width: 16px; height: 16px; stroke-width: 2.2; }
.steps .is-done .step-dot { border-color: var(--public-line); background: var(--public-bg); color: var(--public-fg); }
.steps .is-current { color: var(--ink); font-weight: 600; }
.steps .is-current .step-dot { border-color: var(--accent); background: var(--accent); color: #fff; }
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 24px 0 0; }
.figures > div { padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.figures > .is-ok { border-color: var(--public-line); background: #F3F7F0; }
.figures dt { font-size: var(--fs-1); color: var(--ink-soft); }
.figures dd { margin: 2px 0 0; font-family: var(--font-display); font-size: var(--fs-5); font-weight: 600; line-height: 1.2; font-variant-numeric: lining-nums; }
.figures dd.note { font-family: var(--font-body); font-size: var(--fs-1); font-weight: 400; line-height: var(--lh); color: var(--muted); }
.table { width: 100%; margin-top: 12px; border-collapse: collapse; }
.table th, .table td { padding: 12px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: middle; font-weight: 400; }
.table thead th { padding-block: 8px; border-color: var(--line-strong); font-size: var(--fs-1); font-weight: 500; color: var(--muted); }
.table tbody th { font-weight: 600; }
.table tr > :first-child { padding-inline-start: 0; }
.table tr > :last-child { padding-inline-end: 0; }
.table .cell-action { text-align: end; }
.table tr.is-selected > * { background: var(--sand); }
.table tr.is-selected > :first-child { box-shadow: inset 3px 0 0 var(--bronze); padding-inline-start: 12px; }
[dir="rtl"] .table tr.is-selected > :first-child { box-shadow: inset -3px 0 0 var(--bronze); }
.example { display: inline-block; margin-inline-end: 8px; padding: 1px 8px; border-radius: 6px; background: var(--sand); font-size: var(--fs-1); }
.table + .foot-note, .rep-actions { margin-top: 14px; }
.rep-actions form { display: contents; }
.dest { background: var(--sand); box-shadow: none; }
.dest .facts > div { border-color: var(--line-strong); }

/* policy */
.policy-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; }
.policy-edit { position: sticky; top: 24px; margin-top: 28px; box-shadow: var(--shadow-lg); }
.dialog-head-flat { padding: 0 0 12px; }
[dir="rtl"] .dialog-head-flat { padding: 0 0 12px; }
.rule-preview { padding: 12px 14px; border: 1px solid var(--due-line); border-radius: var(--r); background: var(--due-bg); }
.rule-preview.is-same { border-color: var(--line-strong); background: var(--sand); color: var(--ink-soft); }
.rule-preview ul { margin: 6px 0 0; padding-inline-start: 18px; }
.rule-preview .is-warn { font-weight: 600; color: var(--danger); }
.activity-list .quote { margin-top: 2px; }

/* ---- Checkpoint 3 components ------------------------------------------------------------------------ */
.alert-ok { background: var(--ok-bg); border-color: var(--public-line); color: var(--ok); }
.chip-link { text-decoration: none; color: inherit; border-radius: var(--r-pill); }
.chip-link:hover .chip { border-color: var(--accent); background: #fff; }
.chip-link .chip { min-height: 44px; transition: border-color .15s, background-color .15s; }
.r-missing { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag-stage-completing { background: var(--due-bg); color: var(--due-fg); border-color: var(--due-line); }
.tag-stage-in_review { background: var(--students-bg); color: var(--students-fg); border-color: var(--students-line); }
.tag-stage-published { background: var(--public-bg); color: var(--public-fg); border-color: var(--public-line); }
.work-list form { display: contents; }
.settings-actions { margin-top: 14px; }
.glance .hint { margin-top: 8px; }
.glance dt a { color: var(--ink); }

.entity-group { margin-top: 28px; }
.entity-group h2 { font-size: var(--fs-3); }
.entity-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 12px 0 0; padding: 0; list-style: none; }
.entity-card { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.entity-card:hover { border-color: var(--bronze); box-shadow: var(--shadow); }
.entity-ico { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--sand); color: var(--bronze); }
.entity-text { display: grid; min-width: 0; }
.related-list { list-style: none; margin: 12px 0 0; padding: 0; }
.related-list a { display: grid; gap: 0; min-height: 56px; align-content: center; padding: 8px 0; border-top: 1px solid var(--line-strong); color: var(--ink); text-decoration: none; }
.related-list a:hover b { color: var(--accent-deep); text-decoration: underline; }

.request-list { list-style: none; margin: 8px 0 0; padding: 0; }
.request-list > li { display: grid; gap: 8px; padding: 16px 0; border-top: 1px solid var(--line); }
.request-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; }
.request-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 4px; }
.request-form .alert { flex: 1 1 100%; }
.audit-when { white-space: nowrap; }
.audit-table td { vertical-align: top; }

/* public archive */
.pub-nav { display: flex; gap: 4px; margin-inline-start: 16px; }
.pub-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: var(--r-sm); color: var(--on-dark-soft); text-decoration: none; transition: background-color .15s, color .15s; }
.pub-nav a:hover { background: rgba(246, 238, 221, .08); color: var(--on-dark); }
.pub-nav a[aria-current] { color: var(--gold); font-weight: 600; }
.btn-gold { background: var(--gold); color: var(--ink); font-weight: 600; }
.btn-gold:hover { background: #F2CC78; }
.public-home .pub-main { max-width: none; padding: 0; }
.pub-hero { background: var(--ink); color: var(--on-dark); }
.pub-hero-in, .pub-body { max-width: 1280px; margin: 0 auto; padding-inline: 32px; }
.pub-hero-in { display: grid; gap: 12px; padding-block: 28px 40px; }
.pub-hero h1 { color: #F3E3BF; font-size: clamp(30px, 2vw + 20px, 44px); }
.pub-hero p { color: var(--on-dark-soft); font-size: var(--fs-3); }
.pub-search { display: flex; gap: 10px; max-width: 760px; margin-top: 8px; }
.pub-search input { flex: 1; min-height: 52px; border-color: transparent; border-radius: var(--r-lg); }
.pub-search .btn { min-height: 52px; padding-inline: 24px; border-radius: var(--r-lg); }
.pub-hero :focus-visible { outline-color: var(--gold); }
.pub-hero input:focus { box-shadow: 0 0 0 3px rgba(235, 191, 94, .6); }
.pub-body { padding-block: 24px 64px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.pill { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--surface); color: var(--ink-soft); font-weight: 500; text-decoration: none; transition: border-color .15s, background-color .15s; }
.pill:hover { border-color: var(--field-line); color: var(--ink); }
.pill[aria-current] { border-color: var(--ink); background: var(--ink); color: #F3E3BF; }
.pub-cols { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; margin-top: 16px; }
.pub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; margin: 0; padding: 0; list-style: none; }
.pub-card { display: flex; flex-direction: column; height: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
.pub-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.pub-thumb { display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--sand); color: var(--bronze); }
.pub-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pub-thumb .ico { width: 40px; height: 40px; }
.is-closed .pub-thumb { background: var(--sand-deep); }
.pub-card-body { display: grid; gap: 6px; justify-items: start; padding: 14px 16px 16px; }
.pub-related h2 { font-size: var(--fs-3); }
.closed-box { display: grid; gap: 6px; justify-items: center; padding: 32px 16px; border-radius: var(--r); background: var(--sand); text-align: center; color: var(--ink-soft); }
.closed-box .ico { width: 40px; height: 40px; color: var(--bronze); }
.closed-box b { color: var(--ink); }
.pub-foot .tag { margin-inline-start: 8px; }

.tabbar { display: none; }

/* ---- Tablet --------------------------------------------------------------------------------------- */
@media (max-width: 1179px) {
  .shell { grid-template-columns: 232px minmax(0, 1fr); }
  .main { padding-inline: 28px; }
  .desk { grid-template-columns: minmax(0, 1fr); }
  .item-layout { grid-template-columns: 260px minmax(0, 1fr); }
  .review { grid-template-columns: 280px minmax(0, 1fr); }
  .add-layout { grid-template-columns: minmax(0, 1fr); }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* editing a rule: the edit panel takes the page, the list waits behind "back" */
  .policy-layout { display: block; }
  .policy-editing .policy-main, .policy-editing .policy-head .lead { display: none; }
  .policy-editing .crumb-phone { display: block; }
  .policy-edit { position: static; margin-top: 20px; max-width: 640px; }
  .pub-cols { grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; }
}

/* ---- Phone: dark bar on top, dark bar below, sheets from the bottom --------------------------------- */
@media (max-width: 859px) {
  .side { display: none; }
  .shell { display: block; }
  html { scroll-padding-bottom: calc(var(--tabbar-h) + 24px); }      /* focus stays clear of the bottom bar */
  html:has(body.has-actionbar) { scroll-padding-bottom: calc(var(--tabbar-h) + 96px); }
  html:has(.toasts) { scroll-padding-bottom: calc(var(--tabbar-h) + 190px); }       /* and of a toast */
  html:has(body.has-actionbar):has(.toasts) { scroll-padding-bottom: calc(var(--tabbar-h) + 270px); }
  body.staff { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  .main { padding: 0 0 32px; }
  main { margin-top: 20px; }
  .staff main { padding-inline: 16px; }

  .topbar { flex-wrap: wrap; padding: 10px 16px 14px; background: var(--ink); }
  .topbar :focus-visible { outline-color: var(--gold); }
  .topbar-logo { display: block; }
  .search-wide { display: none; }
  .search-phone { display: block; flex: 1 0 100%; max-width: none; }
  .search input { border-color: transparent; }
  .lang { padding: 0; overflow: hidden; }
  .lang a { min-height: 44px; }
  .topbar .lang { border-color: rgba(246, 238, 221, .4); background: transparent; }
  .topbar .lang a { color: var(--on-dark-soft); }
  .topbar .lang a:hover { color: var(--on-dark); }
  .topbar .lang a[aria-current] { background: var(--gold); color: var(--ink); }
  .topbar .account { background: transparent; border: 1.5px solid var(--gold-soft); color: var(--on-dark); }
  .menu-panel { position: fixed; inset-inline: 8px; top: 64px; width: auto; }

  .btn-add { display: none; }            /* "Add" sits in the bottom bar, in thumb reach */
  .actions, .actions .btn { width: 100%; }
  .btn-sm { min-height: 44px; padding: 0 18px; }
  .panel, .glance { padding: 20px 16px; }
  .panel-wide, .panel-narrow { margin-top: 20px; }
  .desk { margin-top: 20px; gap: 16px; }
  .desk-side { gap: 16px; }
  .sec-head { flex-wrap: wrap; }
  .decisions .more-link { margin-block: -8px; }
  .decision-list { margin-top: 12px; }
  .decision-list li { grid-template-columns: 64px minmax(0, 1fr) auto; }
  .decision-list .thumb { align-self: start; }
  .d-body { grid-column: 2 / -1; }
  .d-date { grid-column: 1 / 3; flex-direction: row; align-items: center; gap: 8px; min-width: 0; }

  .tabbar {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 60;   /* above toasts: an open "More" is never covered */
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--ink);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-width: 0; height: var(--tabbar-h); padding: 0 2px;
    font-size: var(--fs-1); line-height: 1.3; color: var(--on-dark-soft); text-decoration: none;
  }
  .tab-text { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab[aria-current] { color: var(--gold); font-weight: 600; }
  .tab-ico { position: relative; display: grid; place-items: center; height: 30px; }
  .tab-count {
    position: absolute; top: -3px; inset-inline-start: 14px; min-width: 20px; padding: 0 5px; border-radius: var(--r-pill);
    font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; background: var(--gold); color: var(--ink);
  }
  .tab-add .tab-ico { width: 44px; border-radius: var(--r-pill); background: var(--gold); color: var(--ink); }
  .tab-more[open] > summary { color: var(--on-dark); background: rgba(246, 238, 221, .1); }
  .sheet {
    position: fixed; inset-inline: 8px; bottom: calc(var(--tabbar-h) + 8px + env(safe-area-inset-bottom, 0px));
    max-height: calc(100vh - var(--tabbar-h) - 32px); overflow-y: auto; padding: 8px;
    border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
  }
  .sheet ul { list-style: none; margin: 0; padding: 0; }
  .sheet .menu-item { min-height: 48px; }
  .sheet-sep { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
  .sheet-partner { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 12px 12px 6px; border-top: 1px solid var(--line); font-size: var(--fs-1); color: var(--ink-soft); }

  /* The dialog becomes a sheet that rises from the bottom; its buttons stay in thumb reach. */
  .dialog { width: 100%; max-width: none; max-height: 92vh; margin: auto 0 0; border-radius: 20px 20px 0 0; border-width: 1px 0 0; }
  .dialog-head { padding-inline: 16px 8px; }
  [dir="rtl"] .dialog-head { padding: 16px 16px 0 8px; }
  .dialog .decide { padding-inline: 16px; }
  .dialog .dialog-actions { margin-inline: -16px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .dialog-actions .btn { flex: 1; }
  .toasts { inset-inline: 8px; bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom, 0px)); }
  .toast { flex-wrap: wrap; width: 100%; padding: 12px 12px 8px 14px; }
  .toast p { flex-basis: calc(100% - 40px); }
  .toast-close { order: 3; margin-inline-start: auto; }

  .panel + .panel, .panel-list, .policy-main > * + * { margin-top: 16px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .card-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 20px; }
  .facts > div { grid-template-columns: 1fr; gap: 2px; }
  .facts dt { font-size: var(--fs-1); }
  .facts-tight > div { grid-template-columns: 1fr auto; }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
  .filters .field-grow, .filters-go { grid-column: 1 / -1; }
  .filters .field:nth-child(4) { grid-column: 1 / -1; }
  .item-rows li { grid-template-columns: 64px minmax(0, 1fr); align-items: start; }
  .item-rows .r-tags { grid-column: 1 / -1; justify-content: flex-start; }
  .item-rows .r-date { grid-column: 1 / -1; text-align: start; }
  .item-rows .cell-label { display: inline; margin-inline-end: 6px; }
  .item-rows .r-date:empty { display: none; }
  .r-title { display: inline-block; padding-block: 4px; }
  .work-list li { grid-template-columns: 64px minmax(0, 1fr); }
  .work-list .btn { grid-column: 1 / -1; }
  .item-layout, .review, .add-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 16px; }
  .item-body > * + * { margin-top: 16px !important; }
  .pickers { grid-template-columns: minmax(0, 1fr); }
  .choices-row .choice-compact { flex: 1 1 calc(50% - 8px); }
  .choices-row .choice-wide { flex-basis: 100%; }
  .inline-form .btn { flex: 1 1 100%; }
  .file-list a { min-height: 44px; }
  .disclosure > summary, .more-link { min-height: 44px; }

  /* the action bar stays in thumb reach, just above the bottom bar */
  .actionbar {
    position: fixed; inset-inline: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); z-index: 30;
    margin: 0; padding: 10px 16px; border-top: 1px solid var(--line-strong); background: var(--surface);
    box-shadow: 0 -6px 18px rgba(46, 36, 24, .08);
  }
  .actionbar .btn { flex: 1 1 0; min-width: 0; min-height: 48px; padding-inline: 10px; white-space: normal; line-height: 1.25; text-align: center; }
  .actionbar-note { display: none; }
  body.has-actionbar { padding-bottom: calc(var(--tabbar-h) + 72px + env(safe-area-inset-bottom, 0px)); }
  /* while a toast shows, the page can scroll far enough for its last control to clear it */
  body:has(.toasts) { padding-bottom: calc(var(--tabbar-h) + 190px + env(safe-area-inset-bottom, 0px)); }
  body.has-actionbar:has(.toasts) { padding-bottom: calc(var(--tabbar-h) + 270px + env(safe-area-inset-bottom, 0px)); }
  .has-actionbar .toasts { bottom: calc(var(--tabbar-h) + 80px + env(safe-area-inset-bottom, 0px)); }

  /* review: the list, then one item at a time */
  .review-list .detail, .review-detail .queue, .review-detail .review-head { display: none; }
  .review-detail .crumb-phone { display: block; }
  .queue a { min-height: 64px; }
  .detail-image { width: 100%; height: auto; aspect-ratio: 4 / 3; }
  .checklist { display: grid; }
  .review-head .inline-form { width: 100%; }
  .review-head .inline-form .field { flex: 1; }
  .review-head .inline-form .btn { flex: 0 0 auto; }

  .steps { gap: 8px; margin-top: 16px; }
  .steps li { flex: 1 1 calc(50% - 8px); font-size: var(--fs-1); }
  .figures { gap: 10px; margin-top: 16px; }
  .figures > div { padding: 12px 14px; }

  .entity-grid { grid-template-columns: minmax(0, 1fr); }
  .entity-group { margin-top: 20px; }
  .request-form .actions { width: auto; flex: 1 1 100%; flex-wrap: nowrap; }
  .request-form .actions .btn { flex: 1; width: auto; }
  .audit-when { white-space: normal; }

  body.public { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  .pub-nav, .pub-sign { display: none; }                 /* they live in the bottom bar */
  .pub-head .lang { margin-inline-start: auto; }
  .pub-hero-in, .pub-body { padding-inline: 16px; }
  .pub-hero-in { padding-block: 16px 24px; }
  .pub-hero p { font-size: var(--fs-2); }
  .pub-search { flex-direction: column; }
  .pub-search input { flex: none; }
  .pub-cols { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .pub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .pub-card-body { padding: 10px 12px 12px; }
  .pub-card .tag { white-space: normal; }
  .public .tabbar .tab-ico { height: 30px; }

  .signin-shell { display: block; }
  .signin-brand { flex-direction: row; justify-content: flex-start; gap: 16px; padding: 16px; text-align: start; }
  .signin-brand > img { width: 110px; }
  .signin-tagline { font-size: var(--fs-2); }
  .signin-partner { display: none; }
  .signin-main { padding: 16px 16px 40px; }
  .signin-form { padding-block: 16px 0; }
  .pub-head { padding: 12px 16px; flex-wrap: wrap; }
  .pub-head .logo img { height: 40px; }
  .pub-main { padding: 24px 16px 48px; }
  .empty { margin-block: 40px; }
}

/* Under 700 px a table becomes a list of cards, each value with its label. */
@media (max-width: 699px) {
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table-cards, .table-cards tbody { display: block; }
  .table-cards tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .table-cards th, .table-cards td { display: block; padding: 0 !important; border: 0; }
  .table-cards tbody th { grid-column: 1 / -1; }
  .table-cards td:has(select), .table-cards td:last-child:not(:has(.cell-label)) { grid-column: 1 / -1; }
  .table-cards .cell-label { display: block; font-size: var(--fs-1); color: var(--muted); }
  .table-cards .cell-action .btn { width: 100%; }
  .table-cards tr.is-selected { margin-inline: -8px; padding-inline: 8px; border-radius: var(--r-sm); background: var(--sand); }
  .table tr.is-selected > * { background: none; box-shadow: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- D-3a: the public demo (banner on every page, "Try it", report) and the brand's line ---------- */
.demo-banner { padding: 8px 16px; background: var(--gold); color: var(--ink); font-size: var(--fs-1); font-weight: 500; line-height: 1.5; text-align: center; }
.demo-banner a { color: var(--ink); font-weight: 700; white-space: nowrap; }
.brand-beside { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
a.brand-beside:hover span { text-decoration: underline; }
.brand-beside img { height: 32px; width: auto; flex: none; }
/* D-3f: the roles are one group of radio buttons; a role's card shows once it is chosen
   (no script: the label is followed by its card; the cards are ordered after the row). */
.try-pick { margin-top: 28px; }
.try-card h2 { margin: 0 0 6px; }
.try-card { display: none; order: 1; flex: 1 1 100%; gap: 12px; align-content: start; margin-top: 8px; }
.try-role:has(input:checked) + .try-card { display: grid; }
.try-none { order: 1; flex: 1 1 100%; margin-top: 8px; }
.try-pick:has(input:checked) .try-none { display: none; }
.try-login { display: grid; gap: 10px; margin: 0; }
.try-login div { display: grid; gap: 2px; }
.try-login dt { font-size: var(--fs-1); color: var(--muted); }
.try-login dd { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0; }
.try-value { padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); font-size: var(--fs-2); user-select: all; overflow-wrap: anywhere; }
.try-copy { display: none; }
.js .try-copy { display: inline-flex; }
.try-copy.is-copied::after { content: "\00a0\2713"; }
.try-note { margin-top: 16px; }
.try-tour { margin: 0 0 14px; padding-inline-start: 22px; display: grid; gap: 6px; }
/* ---- D-3f: the owner's review of the demo UI --------------------------------------------------------
   Lists without a picture ("My work" and the staff home in omeka mode, B8-4 / B8-2): the
   prototype's rule above keeps a 64 px first column for the picture, so the title fell
   into those 64 px and the button took the wide column. Without a picture: the title
   takes the width, the button keeps its own size. */
.work-list li:not(:has(> .thumb)) { grid-template-columns: minmax(0, 1fr) auto; }
.work-list .r-main { min-width: 0; overflow-wrap: anywhere; }
.work-list li > .btn { justify-self: start; }
.work-comment { min-width: 0; max-width: 100%; }
.work-comment > span { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 859px) {
  .work-list li:not(:has(> .thumb)) { grid-template-columns: minmax(0, 1fr); }
}
/* The side menu: the logo and the partner line stay, only the menu scrolls. */
.side { overflow: hidden; }
.side > .logo, .side > .partner { flex: none; }
.side > nav { flex: 1 1 auto; min-height: 0; margin: -4px; padding: 4px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(246, 238, 221, .35) transparent; }
/* With the demo banner (wide screens): the banner stays at the top and the side menu
   fits in what is left of the window, so its last line is never below the edge. */
@media (min-width: 860px) {
  .is-demo.staff { --demo-banner-h: 40px; }
  .is-demo.staff .demo-banner { position: sticky; top: 0; z-index: 40; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 8px; min-height: var(--demo-banner-h); }
  .is-demo.staff .side { top: var(--demo-banner-h); height: calc(100vh - var(--demo-banner-h)); }
  html:has(body.is-demo.staff) { scroll-padding-top: calc(var(--demo-banner-h) + 16px); }
}
/* "Soon": a menu entry whose page is not built yet. */
.soon { margin-inline-start: auto; flex: none; padding: 1px 8px; border: 1px solid currentColor; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.side nav a .soon { color: var(--on-dark-soft); }
.menu-item .soon, .r-title .soon { color: var(--ink-soft); }
.r-title .soon { margin-inline-start: 10px; font-weight: 600; }
.tab-count.tab-soon { top: -5px; inset-inline-start: 50%; border: 1px solid var(--on-dark-soft); font-size: 10px; font-weight: 600; line-height: 14px; background: var(--ink); color: var(--on-dark); white-space: nowrap; }
.report { margin-top: 20px; }
.report summary { cursor: pointer; font-weight: 500; color: var(--accent); min-height: 44px; display: flex; align-items: center; }
.report form { margin-top: 12px; }
/* ---- D-3g: the footer at the bottom of the window on short pages -----------------------------------
   The page is a column at least the window's height (the banner, the head, the main part,
   the footer); the main part takes what is left, so the footer of a short page sits at the
   bottom of the window and follows the content on a long one. The staff frame and the
   sample sign-in fill the window below the demo banner instead of being one window tall
   under it (a short staff page no longer scrolls by the banner's height). */
body { display: flex; flex-direction: column; min-height: 100dvh; }
body > .pub-main, body > .shell, body > .signin-shell { flex: 1 0 auto; }
body > .pub-main { width: 100%; }
body > .shell, body > .signin-shell { min-height: 0; }
