/* For Member portal: sign-in, authenticator, student workspace and admin console.
   Builds on site.css tokens. Operate mode: scanability first, brand in the details. */

.portal-body { background: var(--paper); min-height: 100vh; display: flex; flex-direction: column; }
.portal-body main { flex: 1; }

.pbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 40; }
.pbar__inner { max-width: 1440px; margin-inline: auto; padding: 12px var(--gutter); display: flex; align-items: center; gap: 18px; min-height: 64px; }
.pbar .brand { color: #fff; }
.pbar .brand__mark { width: 28px; height: 32px; }
.pbar .brand__word { width: 66px; height: 18px; }
.pbar__title { font-weight: 600; color: var(--on-navy-2); padding-left: 18px; border-left: 1px solid rgba(255, 255, 255, 0.22); }
.pbar__user { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 0.875rem; color: var(--on-navy-2); }
.pbar__user strong { color: #fff; font-weight: 600; }
.pbar .btn--ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.35); min-height: 36px; padding: 0 14px; }
.pbar .btn--ghost:hover { background: rgba(255, 255, 255, 0.12); }
.pbar :focus-visible { outline-color: var(--yellow); }

/* ---------------------------------------------------------------- Sign in */
.auth { display: grid; place-items: center; padding: clamp(32px, 7vw, 96px) var(--gutter); }
.auth__card { width: min(440px, 100%); display: grid; gap: 22px; }
.auth__mark { width: 56px; height: 64px; color: var(--navy); }
.auth__card h1 { font-size: clamp(1.8rem, 3vw, 2.3rem); font-weight: 700; letter-spacing: -0.03em; }
.auth__card > p { color: var(--ink-2); }
.auth__foot { font-size: 0.875rem; color: var(--ink-3); border-top: 1px solid var(--line); padding-top: 18px; }
.auth__foot a { color: var(--green); }
.qr { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 20px; align-items: center; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.qr img { width: 168px; height: 168px; image-rendering: pixelated; }
.qr ol { margin: 0; padding-left: 1.1em; display: grid; gap: 8px; font-size: 0.9375rem; color: var(--ink-2); }
.secret { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.875rem; letter-spacing: 0.06em; word-break: break-all; background: var(--paper-2); padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink); }
.code-input { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.6rem !important; letter-spacing: 0.4em; text-align: center; height: 60px !important; }

/* ---------------------------------------------------------------- Forms */
.form { display: grid; gap: 20px; }
.field-row { display: grid; gap: 6px; }
.field-row > label, .field-row > .label { font-weight: 600; font-size: 0.9375rem; }
.field-row .req { color: var(--orange); margin-left: 2px; }
.hint { font-size: 0.8125rem; color: var(--ink-3); }
.input, .textarea, .pselect {
  width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--card); color: var(--ink); font-size: 1rem; line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { min-height: 120px; resize: vertical; }
.textarea--code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.875rem; min-height: 220px; }
.input:hover, .textarea:hover, .pselect:hover { border-color: var(--ink-3); }
.input:focus, .textarea:focus, .pselect:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(20, 34, 63, 0.16); }
.input[aria-invalid="true"] { border-color: #B42318; }
.pselect { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 0.9375rem; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--green); flex: none; }
.check strong { display: block; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding-top: 8px; }
.form-error { color: #B42318; font-size: 0.9375rem; font-weight: 600; }
.form-error:empty { display: none; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 20px; }
legend { font-size: 1.125rem; font-weight: 700; padding: 0; margin-bottom: 4px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn--danger { background: transparent; color: #B42318; border-color: #E6B8B3; }
.btn--danger:hover { background: #FCEDEB; }
.btn--danger.is-armed { background: #B42318; color: #fff; border-color: #B42318; }
.btn--sm { min-height: 34px; padding: 0 14px; font-size: 0.875rem; }
.linkish { background: none; border: 0; padding: 0; color: var(--green); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.image-field { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; align-items: start; }
.image-field__preview { width: 96px; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--paper-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-3); font-size: 0.75rem; text-align: center; }
.image-field__preview img { width: 100%; height: 100%; object-fit: cover; }
.image-field__controls { display: grid; gap: 8px; }
.upload-btn { position: relative; overflow: hidden; justify-self: start; }
.upload-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-btn:focus-within { outline: 2px solid var(--navy); outline-offset: 2px; }
.upload-btn.is-busy { opacity: 0.6; pointer-events: none; }
.inline-input { display: flex; gap: 8px; align-items: center; }
.inline-input .input { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- Workspace layout */
.ws { max-width: 1440px; margin-inline: auto; display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: clamp(24px, 3vw, 48px); padding: 32px var(--gutter) 80px; }
.ws__nav { position: sticky; top: 96px; align-self: start; display: grid; gap: 22px; }
.ws__nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ws__nav h2 { font-size: 0.75rem; font-weight: 700; color: var(--ink-3); letter-spacing: 0.04em; text-transform: uppercase; margin: 0 0 6px 12px; }
.ws__nav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); font-weight: 500; font-size: 0.9375rem; }
.ws__nav a:hover { background: var(--paper-2); }
.ws__nav a[aria-current="page"] { background: var(--navy); color: #fff; font-weight: 600; }
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--orange); color: var(--ink); font-size: 0.75rem; font-weight: 700; }
.ws__nav a[aria-current="page"] .badge { background: var(--yellow); }
.ws__main { min-width: 0; }
.ws__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.ws__head h1 { font-size: clamp(1.7rem, 2.6vw, 2.2rem); font-weight: 700; letter-spacing: -0.025em; }
.ws__head p { color: var(--ink-2); margin-top: 6px; max-width: 70ch; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(20px, 2.4vw, 32px); }
.panel + .panel { margin-top: 24px; }
.panel h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.015em; margin-bottom: 14px; }
.panel--form { max-width: 860px; }

.status { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); margin-bottom: 24px; }
.status__dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--ink-3); }
.status--approved .status__dot { background: var(--emerald); }
.status--pending { background: #FFF8E6; border-color: #F1D79A; }
.status--pending .status__dot { background: var(--orange); }
.status--rejected { background: #FCEDEB; border-color: #E6B8B3; }
.status--rejected .status__dot { background: #B42318; }
.status strong { display: block; }
.status p { color: var(--ink-2); font-size: 0.9375rem; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; text-decoration: none; color: var(--ink); display: grid; gap: 4px; }
a.kpi:hover { border-color: var(--ink-3); }
.kpi strong { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi span { color: var(--ink-2); font-size: 0.875rem; }
.kpi--alert strong { color: #9A5B0C; }

.ptable { width: 100%; border-collapse: collapse; font-size: 0.9375rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ptable th { text-align: left; font-size: 0.75rem; font-weight: 700; color: var(--ink-2); letter-spacing: 0.04em; text-transform: uppercase; padding: 12px 14px; background: var(--paper-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.ptable td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ptable tr:last-child td { border-bottom: 0; }
.ptable tbody tr:hover { background: #FCFAF3; }
.ptable .t-main a { font-weight: 650; color: var(--ink); text-decoration: none; }
.ptable .t-main a:hover { color: var(--green); text-decoration: underline; }
.ptable .t-num { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-2); }
.ptable .t-actions { text-align: right; white-space: nowrap; }
.ptable .t-actions .btn + .btn { margin-left: 6px; }
.table-wrap { overflow-x: auto; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--paper-3); color: var(--ink-2); white-space: nowrap; }
.tag--green { background: #DDF1E6; color: #0A5A35; }
.tag--orange { background: #FDEBC8; color: #7A4A06; }
.tag--red { background: #FCE1DD; color: #8F1D14; }
.tag--navy { background: #DFE5F2; color: var(--navy); }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.toolbar .input { width: min(320px, 100%); min-height: 40px; }

/* People linker */
.linker { display: grid; gap: 12px; }
.linker__selected { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.linker__selected li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 10px; align-items: center; padding: 8px 10px; background: var(--paper-2); border-radius: var(--radius-sm); }
.linker__selected .input { min-height: 36px; padding: 6px 10px; font-size: 0.9375rem; }
.linker__name { font-weight: 600; }
.linker__name .tag { margin-left: 6px; }
.linker__results { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); }
.linker__results:empty { display: none; }
.linker__results button { width: 100%; text-align: left; display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border: 0; background: none; border-bottom: 1px solid var(--line); font-size: 0.9375rem; }
.linker__results li:last-child button { border-bottom: 0; }
.linker__results button:hover, .linker__results button:focus-visible { background: var(--paper-2); outline: none; }
.linker__results span { color: var(--ink-3); font-size: 0.8125rem; }

/* Links editor */
.links-editor { display: grid; gap: 8px; }
.links-editor__row { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.6fr) auto; gap: 8px; }

/* Review diff */
.diff { display: grid; grid-template-columns: 160px minmax(0, 1fr) minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; font-size: 0.9375rem; }
.diff > div { padding: 10px 12px; border-bottom: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.diff > div:nth-last-child(-n + 3) { border-bottom: 0; }
.diff__head { background: var(--paper-2); font-weight: 700; font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2); }
.diff__key { color: var(--ink-2); font-weight: 600; background: var(--paper); }
.diff__changed { background: #FFF8E6; }
.diff__empty { color: var(--ink-3); font-style: italic; }

/* Calendar */
.cal { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal__head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.cal__head h2 { font-size: 1.125rem; font-weight: 700; margin: 0; }
.cal__nav { display: flex; gap: 6px; }
.cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal__dow { padding: 8px; font-size: 0.75rem; font-weight: 700; color: var(--ink-3); text-align: center; border-bottom: 1px solid var(--line); }
.cal__day { min-height: 92px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; align-content: start; gap: 4px; font-size: 0.75rem; }
.cal__day:nth-child(7n) { border-right: 0; }
.cal__day--out { background: var(--paper); color: var(--ink-3); }
.cal__num { font-weight: 700; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.cal__day--today .cal__num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--green); color: #fff; }
.cal__item { display: block; padding: 3px 6px; border-radius: 4px; background: #DFE5F2; color: var(--navy); font-weight: 600; text-decoration: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal__item--event { background: #DDF1E6; color: #0A5A35; }
.agenda { list-style: none; margin: 24px 0 0; padding: 0; border-top: 1px solid var(--line); }
.agenda li { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.agenda time { font-weight: 700; font-variant-numeric: tabular-nums; }
.agenda p { color: var(--ink-2); font-size: 0.9375rem; }

/* Tools */
.tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.tool h2 { font-size: 1.125rem; }
.pathway { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.pathway li { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; }
.pathway strong { display: block; }
.pathway span { color: var(--ink-2); font-size: 0.9375rem; }
.pathway .year { font-weight: 700; color: var(--green); }
.quick { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.quick a { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; }
.quick a:hover { border-color: var(--ink-3); }
.quick span { color: var(--ink-3); font-size: 0.875rem; }
.quick svg { width: 16px; height: 16px; flex: none; }
.slot { border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 24px; display: grid; gap: 6px; align-content: center; color: var(--ink-2); background: transparent; }
.slot strong { color: var(--ink); }

.empty-panel { padding: 32px; text-align: left; color: var(--ink-2); }
.empty-panel strong { display: block; color: var(--ink); font-size: 1.125rem; margin-bottom: 4px; }
.audit-action { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.8125rem; }
.mt-16 { margin-top: 16px; }
.muted-sm { color: var(--ink-3); font-size: 0.8125rem; }

/* Rich-text editor */
.rte { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); overflow: hidden; }
.rte:focus-within { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(20, 34, 63, 0.12); }
.rte__bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px; background: var(--paper-2); border-bottom: 1px solid var(--line); }
.rte__select { min-height: 32px; height: 32px; padding: 0 28px 0 8px; font-size: 0.8125rem; width: auto; }
.rte__btn { display: inline-flex; align-items: center; gap: 4px; min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--ink); font: inherit; font-size: 0.8125rem; font-weight: 600; cursor: pointer; }
.rte__btn svg { width: 14px; height: 14px; flex: none; }
.rte__btn:hover { background: var(--paper-3); }
.rte__btn:focus-visible, .rte__select:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }
.rte__btn[aria-pressed="true"] { background: var(--navy); color: #fff; }
.rte__btn:disabled, .rte__select:disabled { opacity: 0.4; cursor: not-allowed; }
.rte__btn--bold { font-weight: 800; }
.rte__btn--italic { font-style: italic; font-family: var(--serif); }
.rte__btn--underline { text-decoration: underline; }
.rte__file { position: relative; }
.rte__file input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.rte__file.is-busy { opacity: 0.5; pointer-events: none; }
.rte__area { max-width: none; min-height: 260px; max-height: 70vh; overflow: auto; padding: 16px 18px; outline: none; font-size: 1rem; }
.rte__area > :first-child { margin-top: 0; }
.rte__area img, .rte__area video { max-width: 100%; height: auto; }
.rte__source { border: 0; border-radius: 0; width: 100%; min-height: 260px; }
.prose .fs-small, .rte__area .fs-small { font-size: 0.875em; }
.prose .fs-large, .rte__area .fs-large { font-size: 1.25em; }
.prose .fs-xl, .rte__area .fs-xl { font-size: 1.6em; line-height: 1.3; }
.prose .lead, .rte__area .lead { font-size: 1.25em; line-height: 1.5; color: var(--ink-2); }

/* Video preview in the media field */
.image-field__preview video { width: 100%; height: 100%; object-fit: cover; background: #000; }
[data-kind="video"] .image-field { grid-template-columns: 160px minmax(0, 1fr); }
[data-kind="video"] .image-field__preview { width: 160px; aspect-ratio: 16 / 9; }

/* Ordered news picker */
.newslist .linker__selected li { grid-template-columns: minmax(0, 1fr) auto; }
.newslist .linker__name .muted-sm { display: block; font-weight: 400; }
.newslist .inline-input { margin-top: 8px; }

/* Collage manager */
.gallery-mgr { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; counter-reset: gal; }
.gallery-mgr__item { position: relative; display: grid; gap: 6px; padding: 6px; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius-sm); counter-increment: gal; }
.gallery-mgr__item::before { content: counter(gal); position: absolute; top: 10px; left: 10px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--navy); color: #fff; font-size: 0.75rem; font-weight: 700; display: grid; place-items: center; }
.gallery-mgr__item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 4px; }
.gallery-mgr__name { font-size: 0.75rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-mgr__actions { display: flex; gap: 4px; }
.gallery-mgr__actions .btn { min-height: 30px; padding: 0 8px; }
.gallery-mgr__actions .btn:last-child { margin-left: auto; }
.gallery-lib { margin-top: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius-sm); max-height: 420px; overflow: auto; }
.gallery-lib__grid { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.gallery-lib__pick { display: grid; gap: 4px; width: 100%; padding: 4px; border: 2px solid transparent; border-radius: 6px; background: var(--paper-2); cursor: pointer; text-align: left; font: inherit; font-size: 0.6875rem; color: var(--ink-3); }
.gallery-lib__pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-lib__pick img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 3px; }
.gallery-lib__pick[aria-pressed="true"] { border-color: var(--navy); background: #E6EAF2; color: var(--navy); }
.gallery-lib__pick:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

@media (max-width: 960px) {
  .ws { grid-template-columns: 1fr; padding-top: 16px; }
  .ws__nav { position: static; display: block; overflow-x: auto; scrollbar-width: thin; }
  .ws__nav ul { display: flex; gap: 4px; }
  .ws__nav h2 { display: none; }
  .ws__nav a { white-space: nowrap; }
  .ws__nav section + section { margin-top: 6px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tools { grid-template-columns: 1fr; }
  .diff { grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .qr { grid-template-columns: 1fr; justify-items: center; }
  .pbar__title { display: none; }
  .pbar__user > span { display: none; }
  .linker__selected li { grid-template-columns: 1fr auto; }
  .linker__selected li .input { grid-column: 1 / -1; grid-row: 2; }
  .links-editor__row { grid-template-columns: 1fr auto; }
  .links-editor__row .input:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .agenda li { grid-template-columns: 1fr; gap: 4px; }
  .cal__day { min-height: 64px; }
  .cal__item { font-size: 0; padding: 0; width: 8px; height: 8px; border-radius: 50%; }
  .diff { grid-template-columns: 1fr; }
  .diff__head { display: none; }
}
