/* Internal workspace. Shares the studio identity, with a compact operating scale. */
.portal { --gray: #62666f; --line: #dfe2e8; --paper: #f5f6f8; --surface: #fff; --control-line: #aeb5c1; --motion-fast: 150ms; background: var(--paper); font-size: 16px; }
body.portal { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
body.portal > .top, body.portal > .portal-footer { flex: 0 0 auto; }
body.portal > .portal-main { flex: 1 0 auto; }
body.portal > .portal-footer { margin-top: auto; }
.portal ::selection { background: #dbeafe; color: #172554; }
.portal :is(input, textarea) { caret-color: var(--blue); }
.portal :is(a, button, summary, input, select, textarea):focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.portal :is(input, textarea)::placeholder { color: var(--gray); opacity: 1; }
.portal :is(h1, h2, h3, h4) { text-wrap: pretty; }
.portal :is(section, article, aside, div, form) { min-width: 0; }
.portal section { padding: 0; }
.portal section + section { border: 0; }
.portal [id] { scroll-margin-top: 100px; }
.portal .wrap { width: min(1160px, 100% - 64px); }
.portal .narrow { width: min(760px, 100% - 64px); }
.portal .top { background: var(--white); backdrop-filter: none; }
.portal .top .wrap { height: 72px; justify-content: flex-start; gap: 32px; }
.portal .top .brand { letter-spacing: -0.035em; flex-shrink: 0; }
.portal .top .brand span { display: inline; }
.portal .portal-nav { align-self: center; align-items: center; gap: 6px; margin-left: 0; }
.portal .portal-nav a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 14px; border-radius: 8px; font-size: 14px; line-height: 24px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.portal .portal-nav a:hover { background: var(--paper); color: var(--ink); }
.portal .portal-nav a[aria-current=page] { color: var(--blue); background: #e7edfc; font-weight: 600; }

.portal-account { margin-left: auto; }
.account-signout { background: none; border: 1px solid var(--line); min-height: 44px; padding: 9px 14px; border-radius: 8px; color: var(--ink-2); font: inherit; font-size: 14px; cursor: pointer; }
.account-signout:hover { color: var(--ink); border-color: var(--gray); }
.portal-skip { position: fixed; top: -80px; left: 16px; z-index: 30; background: var(--blue); color: white; padding: 12px 18px; border-radius: 8px; }
.portal-skip:focus { top: 12px; color: white; }
.portal-main { padding: 48px 0 72px; min-height: 0; }
.portal-footer { border-top: 1px solid var(--line); padding: 28px 0; background: var(--white); }
.portal-footer .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px; }
.portal-footer nav { display: flex; flex-wrap: wrap; gap: 20px; font-size: 13px; }
.portal-footer nav a { text-decoration: none; color: var(--gray); }
.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.h-page { font-size: 2.25rem; line-height: 1.18; letter-spacing: -0.035em; }
.h-section { font-size: 1.25rem; line-height: 1.35; letter-spacing: -0.025em; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.row-between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 16px; }
.page-description { margin-top: 10px; color: var(--gray); max-width: 65ch; }
.section-description { color: var(--gray); font-size: 15px; margin-top: -8px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.text-action, .back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; text-decoration: none; color: var(--blue); }
.back-link { align-self: flex-start; margin-bottom: 6px; color: var(--gray); }
.portal .btn { justify-content: center; font-size: 14px; min-height: 44px; padding: 8px 16px; border-radius: 8px; line-height: 1.4; white-space: normal; text-align: center; }
.portal .btn-sm { min-height: 38px; padding: 7px 12px; font-size: 13px; }
.portal .btn-ghost { border-color: #cdd2dc; }
.portal .btn-ghost:hover { background: #f4f6fb; border-color: #aeb5c1; }
.btn-danger { background: #b91c1c; color: #fff; border-color: #b91c1c; }
.btn-danger:hover { background: #991b1b; border-color: #991b1b; }
.btn-danger:focus-visible { outline: 3px solid #b91c1c; outline-offset: 3px; }
button.btn { cursor: pointer; font-family: var(--font-brand); font-weight: 700; }
.portal button:disabled { opacity: 0.5; cursor: not-allowed; }
.linkish { background: none; border: 0; padding: 6px 0; color: var(--ink-2); font: inherit; cursor: pointer; text-decoration: underline; text-decoration-color: #aeb5c1; text-underline-offset: 3px; }
.linkish:hover { color: var(--blue); }
.notice { padding: 14px 16px; border-radius: 8px; font-size: 15px; }
.notice-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.notice-ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
[data-flash]:empty { display: none; }

/* Fields and creation flows */
.form { display: flex; flex-direction: column; gap: 22px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-weight: 600; font-size: 14px; color: var(--ink); }
.field .hint { font-size: 13px; color: var(--gray); }
.field :is(input, select, textarea), .manage-row :is(select, input:not([type=file])), .talk-page select { font: inherit; font-size: 15px; padding: 11px 12px; border: 1px solid var(--control-line); border-radius: 8px; background: var(--white); color: var(--ink); min-width: 0; width: 100%; }
.field :is(input, select, textarea):focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
.field textarea { min-height: 112px; resize: vertical; line-height: 1.6; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.prefix { display: flex; align-items: center; border: 1px solid var(--control-line); border-radius: 8px; background: var(--white); overflow: hidden; }
.prefix span { flex: none; padding: 11px 0 11px 12px; color: var(--gray); font-size: 14px; }
.prefix input { flex: 1 1 auto; width: auto; min-width: 0; border: 0 !important; border-radius: 0 !important; padding-left: 2px; outline: none !important; }
.prefix:focus-within { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.check input { margin-top: 4px; }
.portal input[type=checkbox], .portal input[type=radio] { accent-color: var(--blue); width: 17px; height: 17px; flex-shrink: 0; }
.radio-cards { display: grid; gap: 0; border: 1px solid var(--control-line); border-radius: 10px; overflow: hidden; }
.radio-card { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-top: 1px solid var(--line); cursor: pointer; background: var(--white); }
.radio-card:first-child { border-top: 0; }
.radio-card:has(input:checked) { background: #eff4ff; }
.radio-card input { margin-top: 4px; }
.radio-card strong { font-size: 14px; font-weight: 600; }
.radio-card p { font-size: 13px; color: var(--gray); margin-top: 3px; }
.form-page { padding: 32px !important; background: var(--white); border: 1px solid var(--line); border-radius: 12px; }
.form-page .form { margin-top: 12px; }
.form-page .page-description { margin-top: -8px; }
.form-page .form > div:last-child { padding-top: 8px; }
input[type=file] { max-width: 100%; font: inherit; font-size: 13px; color: var(--gray); }
input[type=file]::file-selector-button { border: 1px solid var(--control-line); border-radius: 6px; padding: 8px 10px; margin-right: 10px; background: var(--white); color: var(--ink-2); font: inherit; cursor: pointer; }

/* Shared material lists */
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--white); }
.list-row { display: flex; gap: 18px; align-items: center; padding: 22px 24px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.list-row:first-child { border-top: 0; }
a.list-row:hover { background: #f6f8fc; color: inherit; }
.list-row .ic { flex: none; width: 40px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--blue); }
.list-row .main { flex: 1 1 auto; min-width: 0; }
.list-row .t { font-family: var(--font-brand); font-weight: 700; font-size: 16px; line-height: 1.5; letter-spacing: -0.015em; }
.list-row .s { font-size: 14px; color: var(--gray); margin-top: 5px; }
.list-row .side { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--gray); text-align: right; flex: none; }
.list-row .side br { display: none; }
.row-arrow { display: inline-flex; }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 28px; color: var(--gray); font-size: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.empty p { font-size: 16px; font-weight: 500; color: var(--ink-2); }
.empty .btn { margin-top: 8px; }
.empty.compact { background: transparent; border: 0; padding: 0; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 5px; font-size: 11px; font-weight: 500; background: #edf0f4; color: #4b5563; white-space: nowrap; }
.pill-blue { background: #e8efff; color: #1e40af; }
.pill-green { background: #e7f4ed; color: #166534; }
.pill-amber { background: #fef3c7; color: #92400e; }
.pill-red { background: #fee2e2; color: #991b1b; }
.dot-new { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-left: 4px; }

/* Public identity and teaching/research index */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.avatar-text { background: #e7edfc; color: var(--blue); font-family: var(--font-brand); font-weight: 700; }
.profile-layout { display: grid; grid-template-columns: 272px minmax(0,1fr); gap: 64px; align-items: start; }
.profile-identity { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding-top: 8px; }
.profile-identity .avatar { margin-bottom: 6px; }
.profile-identity .h-page { font-size: 2rem; }
.profile-meta { color: var(--ink-2); font-size: 15px; line-height: 1.6; }
.profile-handle { color: var(--gray); font-size: 13px; }
.bio { font-size: 15px; line-height: 1.75; white-space: pre-line; padding-top: 12px; max-width: 68ch; }
.profile-links { display: flex; flex-direction: column; gap: 10px; font-size: 14px; padding: 8px 0; }
.profile-links a { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.profile-links svg { color: var(--gray); }
.section-nav { display: flex; flex-wrap: wrap; gap: 24px; border-bottom: 1px solid var(--line); padding: 0 0 18px; margin-bottom: 32px; }
.section-nav a { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink-2); text-decoration: none; }
.section-nav span { font-size: 11px; color: var(--gray); padding: 1px 5px; background: #e8ebf0; border-radius: 4px; }
.content-section { margin-bottom: 36px; }
.content-section:last-child { margin-bottom: 0; }
.group-label { font: 500 13px var(--font-text); color: var(--gray); margin: 24px 0 12px; }
.course-code { color: var(--blue); font: 400 12px var(--font-mono); margin-bottom: 5px; }
.pubs { display: flex; flex-direction: column; gap: 20px; }
.publication-year { display: grid; grid-template-columns: 52px minmax(0,1fr); gap: 20px; border-top: 1px solid var(--line); padding-top: 20px; }
.pub-year { font-family: var(--font-brand); font-weight: 700; font-size: 13px; color: var(--gray); padding-top: 3px; }
.pub { display: flex; flex-direction: column; gap: 7px; padding: 18px 0; border-top: 1px solid var(--line); }
.publication-year .pub:first-child { border: 0; padding-top: 0; }
.publication-year .pub:last-child { padding-bottom: 0; }
.pub .t { margin: 0; font-family: var(--font-brand); font-weight: 700; font-size: 15px; line-height: 1.5; letter-spacing: -0.015em; }
.pub .t a { text-decoration: none; }
.pub .t a:hover { text-decoration: underline; }
.pub .a { font-size: 13px; color: var(--ink-2); }
.pub .v { font-size: 12px; color: var(--gray); }
.pub.is-hidden .t { color: var(--gray); }
.pub-actions { display: flex; gap: 18px; font-size: 13px; }
.projects { display: flex; flex-direction: column; gap: 20px; }
.project { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 20px; }
.project .t { font-size: 17px; line-height: 1.5; }
.project .t a { text-decoration: none; }
.project p { font-size: 14px; color: var(--ink-2); max-width: 65ch; }
.project .y { font-size: 12px; color: var(--gray); }

/* The signed-in workspace */
.workspace-grid { display: grid; grid-template-columns: minmax(0,1fr) 280px; gap: 40px; align-items: start; }
.workspace-profile { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.workspace-profile h2 { font-size: 18px; line-height: 1.4; }
.workspace-profile .btn { font-size: 12px; margin-top: 6px; width: 100%; padding-inline: 10px; }
.workspace-help { display: flex; flex-direction: column; gap: 14px; padding: 28px 4px; }
.workspace-help h3 { font-size: 16px; }
.workspace-help p { color: var(--gray); font-size: 14px; }
.workspace-help a { font-size: 13px; }

/* Settings: stable navigation beside focused form sections. */
.settings-layout { display: grid; grid-template-columns: 204px minmax(0,1fr); gap: 40px; align-items: start; }
.settings-sidebar { position: sticky; top: 108px; }
.settings-nav { display: flex; flex-direction: column; gap: 4px; }
.settings-nav a { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; border-radius: 7px; text-decoration: none; font-size: 14px; }
.settings-nav a:hover { background: #e9edf5; }
.settings-nav a[aria-current=page] { color: var(--blue); background: #e7edfc; font-weight: 600; }
.settings-nav span { font-size: 12px; color: var(--gray); }
.sidebar-note { margin: 24px 14px; font-size: 12px; color: var(--gray); line-height: 1.8; }
.sidebar-note a { color: var(--blue); text-decoration: none; font-size: 14px; }
.settings-content { display: flex; flex-direction: column; gap: 24px; }
.portal .settings-section { padding: 28px 32px; background: var(--white); border: 1px solid var(--line); border-radius: 12px; }
.settings-section .field-row { grid-template-columns: repeat(2,minmax(0,1fr)); }
.settings-section[data-section=academic] .field-row { grid-template-columns: 1fr; }
.photo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; padding-bottom: 24px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.photo-row .avatar { width: 64px; height: 64px; }
.photo-row > .stack { flex: 1; }
.photo-row .manage-row { gap: 10px; }
.photo-row .manage-row input { flex-basis: 100%; }
.settings-section .form.manage { border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 22px 0 0; background: transparent; }
.save-status { font-size: 13px; color: var(--gray); min-height: 1.4em; }
.save-status.is-busy { color: var(--ink-2); }
.save-status.is-ok { color: #166534; }
.save-status.is-error { color: #991b1b; }
form[aria-busy=true] button.btn { opacity: 0.6; cursor: progress; }

/* Course reader and instructor controls */
.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; color: var(--gray); margin-bottom: 12px; }
.breadcrumb a { color: var(--gray); text-decoration: none; }
.course-head { display: flex; flex-direction: column; gap: 10px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.course-head .h-page { max-width: 27ch; font-size: 2.25rem; }
.course-head .lead { font-size: 16px; margin: 2px 0 8px; }
.course-head .row { margin-top: 10px; }
.course-head .row .btn:first-of-type { margin-left: auto; }
.course-layout { display: grid; grid-template-columns: 204px minmax(0,1fr); gap: 40px; align-items: start; margin-top: 12px; }
.course-sidebar { position: sticky; top: 96px; max-height: calc(100vh - 120px); overflow: auto; scrollbar-width: thin; scrollbar-color: #aeb5c1 transparent; }
.course-outline { display: flex; flex-direction: column; gap: 2px; }
.course-outline a { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--ink-2); text-decoration: none; border-radius: 6px; padding: 9px 12px; }
.course-outline a:hover { background: #e9edf5; }
.course-outline .outline-week { padding-block: 7px; font-size: 12px; color: var(--gray); }
.outline-week span:last-child { font-size: 11px; }
.course-outline .is-current { color: var(--blue); background: #e7edfc; font-weight: 600; }
.course-content { display: flex; flex-direction: column; gap: 20px; }
.course-content > .h-section { margin-top: 12px; }
.course-content > .section-heading { margin-top: 12px; margin-bottom: 0; }
.weeks { display: flex; flex-direction: column; gap: 16px; }
.week { border: 1px solid var(--line); border-radius: 10px; background: var(--white); overflow: hidden; }
.week-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 20px 22px 16px; }
.week-head .n { font-size: 12px; color: var(--gray); min-width: 56px; white-space: nowrap; }
.week-head .topic { font-family: var(--font-brand); font-weight: 700; font-size: 15px; flex: 1 1 200px; line-height: 1.5; }
.week-head .date { font-size: 12px; color: var(--gray); font-variant-numeric: tabular-nums; }
.week.is-upcoming { background: #fafbfc; }
.week.is-current { border-color: var(--blue); }
.week.is-current .week-head { background: #f1f5ff; }
.files { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 22px 20px; }
.file { display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; text-decoration: none; color: var(--ink-2); background: var(--white); max-width: 100%; }
.file:hover { border-color: var(--blue); color: var(--blue); }
.file svg { flex: none; color: var(--blue); }
.file .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .meta { color: var(--gray); font-size: 11px; white-space: nowrap; }
.file.is-hidden { border-style: dashed; color: var(--gray); background: var(--paper); }
.files-empty { padding: 0 22px 20px; font-size: 13px; color: var(--gray); }
.manage { border: 1px solid var(--line); border-radius: 10px; padding: 20px; background: var(--white); }
.manage h3 { font-size: 16px; margin: 20px 0 12px; }
.manage-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.manage-row :is(select, input:not([type=file])) { width: auto; max-width: 100%; flex: 1 1 150px; font-size: 13px; padding: 8px 10px; }
.week-editor { border-top: 1px solid var(--line); }
.week-editor > summary { padding: 12px 22px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.week-editor > summary span { color: var(--gray); margin-left: 8px; }
.week-manage { padding: 16px 22px 20px; display: flex; flex-direction: column; gap: 16px; align-items: stretch; font-size: 14px; background: #fafbfc; }
.week-manage > form + form { border-top: 1px solid var(--line); padding-top: 16px; }
.week-manage input[type=file] { flex: 1 1 180px; min-width: 0; }
.link-box { display: flex; gap: 8px; align-items: center; }
.link-box input { width: 100%; font: 13px var(--font-mono); padding: 11px 12px; border: 1px solid var(--control-line); border-radius: 8px; background: var(--white); min-width: 0; }
details.more > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); }
details.more > summary span { margin-left: 10px; color: var(--gray); font-weight: 400; font-size: 12px; }
details.more[open] > summary { margin-bottom: 20px; }
details.more > summary:hover, .week-editor > summary:hover { color: var(--blue); }
.management-disclosure { padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
table.roster { display: block; overflow-x: auto; max-width: 100%; width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 12px; }
table.roster th, table.roster td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.roster th { font-weight: 600; color: var(--gray); white-space: nowrap; }
table.roster code { overflow-wrap: anywhere; }
.viewer-frame { width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 10px; background: #111; }
.viewer-page { gap: 16px; }
.viewer-page .viewer-bar { padding: 16px 20px; background: var(--white); border: 1px solid var(--line); border-radius: 10px; }
.viewer-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; font-size: 14px; color: var(--ink-2); }
.talk-page .manage { margin-top: 12px; }
.talk-page .manage > .row { margin-top: 20px; }
.talk-page select { width: auto; }

/* Small feedback only; no navigation or content entrance choreography. */
@media (prefers-reduced-motion: no-preference) {
  .portal :is(.btn, .list-row, .settings-nav a, .course-outline a, .save-status) { transition: color var(--motion-fast) ease, background-color var(--motion-fast) ease, border-color var(--motion-fast) ease; }
}
@media (max-width: 1000px) {
  .portal .top .wrap { gap: 20px; }
  .portal-nav a { padding-inline: 12px; }
  .profile-layout { grid-template-columns: 240px minmax(0,1fr); gap: 36px; }
  .workspace-grid { grid-template-columns: minmax(0,1fr) 248px; gap: 24px; }
  .settings-layout, .course-layout { grid-template-columns: 172px minmax(0,1fr); gap: 24px; }
  .portal .settings-section { padding: 24px; }
  .list-row { padding: 18px; }
  .list-row .side { flex-direction: column; gap: 6px; align-items: flex-end; }
}
@media (max-width: 760px) {
  .portal .wrap, .portal .narrow { width: calc(100% - 40px); }
  .portal .top .wrap { flex-wrap: wrap; height: auto; gap: 0; padding-top: 14px; }
  .portal .top .brand { height: 38px; font-size: 18px; }
  .portal-account { order: 1; }
  .portal .portal-nav { order: 2; width: 100%; margin: 10px 0 12px; gap: 6px; }
  .portal .portal-nav a { padding: 10px 12px; font-size: 13px; }
  .portal-main { padding-top: 28px; }
  .portal [id] { scroll-margin-top: 136px; }
  .h-page, .course-head .h-page { font-size: 1.875rem; }
  .page-heading { align-items: flex-start; flex-wrap: wrap; gap: 18px; }
  .profile-layout { grid-template-columns: 1fr; gap: 32px; }
  .profile-identity { display: grid; grid-template-columns: 64px minmax(0,1fr); gap: 8px 18px; }
  .profile-identity .avatar { grid-row: 1 / 4; width: 64px !important; height: 64px !important; font-size: 27px !important; margin: 0; }
  .profile-identity .h-page { font-size: 1.625rem; }
  .profile-identity .profile-meta { font-size: 14px; }
  .profile-identity .bio, .profile-identity .profile-links, .profile-identity .btn { grid-column: 1 / -1; }
  .profile-identity .bio { margin-top: 12px; }
  .profile-links { flex-direction: row; flex-wrap: wrap; gap: 10px 18px; }
  .profile-identity .btn { justify-self: start; margin-top: 10px; }
  .section-nav { gap: 16px; padding-bottom: 14px; margin-bottom: 28px; }
  .section-nav a { font-size: 13px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .workspace-aside { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  .workspace-help { padding-top: 8px; }
  .settings-layout, .course-layout { grid-template-columns: 1fr; gap: 24px; }
  .settings-sidebar { position: static; }
  .settings-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .settings-nav a { padding: 8px 10px; gap: 8px; font-size: 13px; background: var(--white); }
  .sidebar-note { display: none; }
  .course-sidebar { position: static; max-height: none; overflow: visible; }
  .course-outline { flex-direction: row; flex-wrap: wrap; }
  .course-outline .outline-week { display: none; }
  .course-outline a { background: var(--white); }
  .course-head { padding-bottom: 24px; }
  .week-head .date { flex-basis: 100%; }
  .week-head .topic { flex-basis: calc(100% - 84px); }
}
@media (max-width: 480px) {
  .portal .wrap, .portal .narrow { width: calc(100% - 32px); }
  .portal .settings-section, .portal .form-page { padding: 22px 18px !important; }
  .settings-section .field-row, .field-row { grid-template-columns: 1fr; }
  .settings-section .field > .field-row { grid-template-columns: minmax(0,1fr) minmax(0,1.4fr); gap: 8px; }
  .list-row { gap: 12px; padding: 18px 16px; flex-wrap: wrap; }
  .list-row .ic { display: none; }
  .list-row .main { flex-basis: 100%; }
  .list-row .side { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; text-align: left; }
  .list-row .side:empty { display: none; }
  .publication-year { grid-template-columns: 1fr; gap: 12px; }
  .workspace-aside { grid-template-columns: 1fr; }
  .workspace-help { padding: 12px 4px; }
  .prefix { flex-wrap: wrap; }
  .prefix span { padding-bottom: 0; width: 100%; font-size: 12px; }
  .prefix input { padding-left: 12px; width: 100%; }
  .week-head, .week-manage { padding-inline: 16px; }
  .files, .files-empty { padding-inline: 16px; }
  .week-editor > summary { padding-inline: 16px; }
  .week-editor > summary span { display: none; }
  details.more > summary span { display: block; margin: 5px 0 0 16px; }
  .course-head .row .btn { margin-left: 0; }
  .portal-footer .brand { font-size: 16px !important; }
}
@media (prefers-reduced-motion: reduce) {
  html:has(.portal) { scroll-behavior: auto; }
}

@media (max-width: 760px) {
  .field :is(input, select, textarea) { font-size: 16px; }
}

/* Real profile subpages, with the active page visible at every viewport. */
.profile-tabs { gap: 0; padding-bottom: 0; flex-wrap: wrap; }
.profile-tabs a { position: relative; padding: 14px 12px 16px; min-height: 48px; }
.profile-tabs a:hover { background: #e9edf5; }
.profile-tabs a[aria-current=page] { color: var(--blue); font-weight: 600; }
.profile-tabs a[aria-current=page]::after { content: ''; position: absolute; bottom: -1px; height: 3px; left: 12px; right: 12px; background: var(--blue); border-radius: 3px; }
.profile-about { padding-top: 0; font-size: 16px; }
.profile-facts { margin: 28px 0 0; display: grid; gap: 20px; }
.profile-facts > div { border-top: 1px solid var(--line); padding-top: 16px; }
.profile-facts dt { color: var(--gray); font-size: 13px; margin-bottom: 6px; }
.profile-facts dd { margin: 0; font-size: 15px; }
@media (max-width: 760px) {
  .profile-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--control-line) transparent; }
  .profile-tabs a { flex-shrink: 0; }
}

.profile-pinned { margin-top: 40px; }
.pin-editor { margin-top: 28px; }
.pin-editor > p { margin: 16px 0; }
.pin-editor fieldset { border: 0; padding: 0; margin: 24px 0; min-width: 0; }
.pin-editor legend { font-weight: 600; margin-bottom: 8px; }
.pin-choice { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.pin-choice input { width: 18px; height: 18px; flex-shrink: 0; margin-top: 3px; accent-color: var(--blue); }

/* Publication, project and award management share one quiet collection pattern. */
.collection-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.collection-toolbar form { margin: 0; }
.collection-sort { display: flex; align-items: center; gap: 8px; margin-left: auto !important; font-size: 13px; }
.collection-sort select { min-height: 38px; max-width: 210px; border: 1px solid var(--control-line); background: white; padding: 6px 10px; border-radius: 8px; font: inherit; }
.collection-year > .group-label { display: flex; justify-content: space-between; padding-block: 16px; margin: 0; }
.collection-entry { padding: 24px 0; border-top: 1px solid var(--line); }
.collection-entry.is-hidden { background: var(--paper); padding-inline: 16px; }
.entry-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.entry-heading .group-label { margin: 0; }
.entry-status { margin-left: auto; color: var(--gray); font-size: 12px; white-space: nowrap; }
.source-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.source-badge { font-size: 11px; line-height: 1.5; font-weight: 600; padding: 3px 7px; background: #e7edfc; color: var(--blue); border-radius: 4px; }
.entry-content { display: grid; grid-template-columns: minmax(0,1fr); gap: 24px; }
.collection-entry :is(h3,h4) { font-size: 16px; line-height: 1.5; letter-spacing: 0; }
.collection-entry h4 a { color: var(--ink); text-decoration: none; }
.collection-entry h4 a:hover { color: var(--blue); text-decoration: underline; }
.entry-authors, .entry-meta { color: var(--gray); font-size: 13px; line-height: 1.7; margin-top: 8px; }
.entry-actions { display: flex; flex-wrap: wrap; align-items: start; gap: 16px; margin-top: 16px; }
.entry-actions form { margin: 0; }
.action-confirm > summary { cursor: pointer; color: var(--gray); font-size: 13px; padding-block: 10px; }
.confirm-panel { padding: 16px; border: 1px solid var(--line); border-radius: 8px; max-width: 320px; background: var(--paper); font-size: 13px; }
.confirm-panel p { margin-bottom: 12px; }
.editor-modal { width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); margin: auto; overflow-y: auto; border: 1px solid var(--line); border-radius: 16px; padding: 28px; color: var(--ink); background: white; }
.editor-modal::backdrop { background: rgb(15 23 42 / 45%); }
.modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.editor-modal > p { margin-bottom: 20px; }
.editor-modal .form { margin: 0; padding: 0; border: 0; }
.editor-modal .row [data-status] { margin-left: auto; text-align: right; }
@media (max-width: 760px) {
  .entry-content { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .collection-sort { width: 100%; flex-wrap: wrap; margin-left: 0 !important; }
  .editor-modal { padding: 20px; }
}

.profile-link-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.5fr) auto; align-items: start; gap: 8px; margin-bottom: 12px; }
@media (max-width: 760px) {
  .profile-link-row { grid-template-columns: minmax(0,1fr) auto; }
  .profile-link-row input { grid-column: 1; }
  .profile-link-row button { grid-column: 2; grid-row: 1 / 3; }
}

/* Keep the navigation frame steady while the selected page changes. */
@media (prefers-reduced-motion: no-preference) {
  .portal { --motion-page: 160ms; --ease-arrive: cubic-bezier(0.16, 1, 0.3, 1); }
  /* One content fade; document snapshots and layout transforms cause jumps
     when navigating between sections with different heights or scroll offsets. */
  :is(.profile-content, .settings-content) {
    animation: portal-content-enter var(--motion-page) ease-out;
  }
  .portal :is(.portal-nav a, .profile-tabs a, input, select, textarea, .account-signout) {
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  }
  .portal :is(.notice, .save-status.is-ok, .save-status.is-error, .profile-link-row, .confirm-panel) {
    animation: portal-feedback 180ms ease-out;
  }
  .editor-modal[open] { animation: portal-dialog-enter 220ms var(--ease-arrive); }
  .editor-modal[open]::backdrop { animation: portal-feedback 180ms ease-out; }
  @supports (transition-behavior: allow-discrete) {
    .editor-modal {
      opacity: 0; transform: translateY(8px) scale(.99);
      transition: opacity 160ms ease-out, transform 220ms var(--ease-arrive), display 220ms allow-discrete, overlay 220ms allow-discrete;
    }
    .editor-modal[open] { opacity: 1; transform: none; animation: none; }
    .editor-modal::backdrop { opacity: 0; transition: opacity 160ms ease-out, display 220ms allow-discrete, overlay 220ms allow-discrete; }
    .editor-modal[open]::backdrop { opacity: 1; animation: none; }
    @starting-style {
      .editor-modal[open] { opacity: 0; transform: translateY(8px) scale(.99); }
      .editor-modal[open]::backdrop { opacity: 0; }
    }
  }
}
@keyframes portal-content-enter { from { opacity: .75; } to { opacity: 1; } }
@keyframes portal-feedback { from { opacity: .35; } to { opacity: 1; } }
@keyframes portal-dialog-enter { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

.confirmation-modal { max-width: 480px; }
.confirmation-modal .confirmation-item { margin: 20px 0 12px; font-weight: 600; line-height: 1.5; }
.confirmation-modal > p { font-size: 14px; color: var(--gray); }
.confirmation-actions { justify-content: flex-end; margin-top: 24px; }
.entry-icon-action { gap: 8px; }

/* Feedback floats above the page instead of changing form or toolbar geometry. */
.toast-stack { position: fixed; z-index: 1000; right: 24px; bottom: 24px; width: min(420px, calc(100vw - 32px)); display: grid; gap: 12px; pointer-events: none; max-height: calc(100dvh - 48px); overflow-y: auto; }
.toast { display: flex; align-items: flex-start; gap: 16px; padding: 16px 18px; border-radius: 12px; background: #151515; color: #fff; box-shadow: 0 12px 32px rgb(0 0 0 / 18%); font: 400 14px/1.55 var(--font-text); pointer-events: auto; overflow-wrap: anywhere; }
.toast-error { background: #991b1b; }
.toast > span { flex: 1; }
.toast button { flex-shrink: 0; display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 6px; color: inherit; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; }
.toast button:hover { background: rgb(255 255 255 / 15%); }
.toast button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
[data-toast] { position: fixed; z-index: 1000; bottom: 24px; right: 24px; max-width: min(420px, calc(100vw - 32px)); }
.button-loading { position: relative !important; color: transparent !important; cursor: wait !important; }
.button-loading > :not(.button-spinner) { visibility: hidden; }
.button-spinner { position: absolute; width: 18px; height: 18px; top: calc(50% - 9px); left: calc(50% - 9px); border: 2px solid var(--gray); border-top-color: var(--blue); border-radius: 50%; }
.btn-primary .button-spinner, .btn-danger .button-spinner { border-color: rgb(255 255 255 / 40%); border-top-color: white; }
@media (prefers-reduced-motion: no-preference) {
  .button-spinner { animation: feedback-spin 700ms linear infinite; }
  @keyframes feedback-spin { to { transform: rotate(360deg); } }
  .toast { animation: feedback-enter 160ms ease-out; }
  @keyframes feedback-enter { from { opacity: .5; transform: translateY(6px); } }
}
@media (max-width: 600px) { .toast-stack { right: 16px; bottom: 16px; } }

.publication-pin[aria-pressed="true"] { color: #1d4ed8; background: #dbeafe; border-color: #bfdbfe; }

.choice-buttons { border: 0; margin: 0; padding: 0; min-width: 0; }
.choice-buttons legend { font-size: 12px; color: var(--gray); margin-bottom: 7px; }
.choice-buttons > div { display: flex; flex-wrap: wrap; gap: 6px; }
.choice-buttons label { position: relative; cursor: pointer; }
.portal .choice-buttons input[type=radio] { position: absolute; opacity: 0; width: 1px; height: 1px; padding: 0; margin: 0; }
.choice-buttons span { display: block; padding: 9px 12px; border: 1px solid var(--control-line); border-radius: 7px; font-size: 13px; line-height: 20px; color: var(--ink-2); background: var(--white); }
.choice-buttons input:checked + span { background: #e7edfc; color: #1d4ed8; border-color: #1d4ed8; }
.choice-buttons input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 3px; }
.choice-buttons input:disabled + span { opacity: .55; cursor: default; }
.management-heading { font-size: 15px; line-height: 1.5; margin-bottom: 16px; }
.week-editor > .management-heading { padding: 16px 22px 0; margin: 0; }
.management-heading span { font-family: var(--font-text); font-size: 13px; font-weight: 400; color: var(--gray); margin-left: 8px; }
.week-manage .roster { width: 100%; }
.manage-row .choice-buttons { flex: 1 1 240px; }
.course-layout.course-single-panel { grid-template-columns: minmax(0, 1fr); }
.course-outline a[aria-current=page] { color: var(--blue); background: #e7edfc; font-weight: 600; border-radius: 6px; }
.course-breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.course-breadcrumb a { text-decoration: underline; text-underline-offset: 3px; }
.course-breadcrumb [aria-current=page] { color: var(--ink-2); }
.course-term-group + .course-term-group { margin-top: 28px; }
.course-term-group > .group-label { margin-bottom: 12px; }

/* Course panels retain their inset after disclosure sections became tabs. */
.portal .course-content > section.manage,
.portal .course-content > section.management-disclosure { padding: 28px; }
.course-content > .manage > .management-heading,
.course-content > .management-disclosure > .management-heading { margin: 0 0 20px; }
.course-page > .section-nav { margin-bottom: 0; }
.course-page > .course-layout { margin-top: 4px; }
@media (max-width: 700px) {
  .portal .course-content > section.manage,
  .portal .course-content > section.management-disclosure { padding: 20px; }
  .course-head .row .btn:first-of-type { margin-left: 0; }
}
