/* Masdar app styles. Layout uses logical properties (inline-start/end) so Arabic mirrors.
   Breakpoints: phone < 720 (top bar, search dock, tab bar) · tablet 720–1199 (side rail)
   · desktop ≥ 1200 (top bar with navigation). */

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--body-size);
  line-height: var(--body-lh);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--t-mid) var(--ease), color var(--t-mid) var(--ease);
}
h1, h2, h3, p { margin: 0; }
a { color: var(--accent-text); }
button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
bdi.code, .code {
  direction: ltr;
  unicode-bidi: isolate;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-2); }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; z-index: 50; padding: 10px 16px; background: var(--ink); color: var(--ground); border-radius: var(--radius-2); }
.skip:focus { top: 8px; }

/* ---------- wordmark ---------- */
.wordmark { display: inline-flex; align-items: center; gap: .32em; font-weight: 600; color: var(--ink); text-decoration: none; line-height: 1; }
.wordmark [lang="en"] { letter-spacing: -0.02em; }
.wordmark .margin { width: 2px; height: .95em; background: var(--accent); flex: 0 0 auto; }
[dir="rtl"] .wordmark { flex-direction: row-reverse; } /* Arabic-first lockup: مصدر | Masdar */
.meem {
  position: relative; width: 44px; height: 44px; flex: 0 0 auto; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink);
}
.meem span { font-size: 24px; line-height: 24px; font-weight: 600; margin-top: -4px; }
.meem::after { content: ""; position: absolute; right: 8px; top: 8px; bottom: 8px; width: 2px; background: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 16px; border-radius: var(--radius-2); border: 1.5px solid transparent;
  font-size: 15px; font-weight: 500; line-height: 20px; text-decoration: none; cursor: pointer;
  background: transparent; color: var(--ink);
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn-outline { border-color: var(--ink); }
.btn-outline:hover { background: var(--sunken); }
.btn-ghost:hover { background: var(--sunken); }
.icon-btn {
  width: 44px; height: 44px; flex: 0 0 auto; border: 0; border-radius: 22px; background: transparent; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none;
  transition: background-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--sunken); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.ar { font-size: 18px; font-weight: 600; }
.icon-btn svg, .btn svg { flex: 0 0 auto; }
.dl-btn {
  width: 44px; height: 44px; flex: 0 0 auto; border-radius: 22px; border: 1px solid var(--rule-strong); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.dl-btn:hover { background: var(--ink); border-color: var(--ink); color: var(--ground); }
.dl-btn:active { transform: scale(.94); }
.chev { flex: 0 0 auto; }
[dir="rtl"] .chev { transform: scaleX(-1); } /* chevrons mirror; download, upload and search never do */

/* ---------- shell: top bar ---------- */
.topbar {
  position: relative; z-index: 10; display: flex; align-items: center; gap: 4px;
  padding: 14px 32px; min-height: 72px;
}
.topbar .wordmark { font-size: 22px; }
.topbar .brand { margin-inline-end: auto; text-decoration: none; border-radius: var(--radius-2); }
.topbar .nav { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.topbar .sep { width: 1px; height: 24px; margin: 0 8px; background: var(--rule); }
.nav-link {
  position: relative; min-height: 44px; display: inline-flex; align-items: center; gap: 6px;
  padding: 0 14px; border-radius: 10px; font-size: 15px; line-height: 20px; color: var(--ink); text-decoration: none;
  transition: background-color var(--t-fast) var(--ease);
}
.nav-link:hover { background: var(--sunken); }
.nav-link[aria-current="page"]::after {
  content: ""; position: absolute; inset-inline: 14px; bottom: 6px; height: 2px; background: var(--accent);
  transform-origin: left; animation: m-wipe-x var(--t-mid) var(--ease) both;
}
[dir="rtl"] .nav-link[aria-current="page"]::after { transform-origin: right; }
.nav-link.contribute { border: 1.5px solid var(--ink); margin-inline-start: 4px; }
.nav-link.contribute[aria-current="page"] { background: var(--accent-tint); border-color: var(--accent); color: var(--accent-text); }
.nav-link.contribute[aria-current="page"]::after { display: none; }
.topbar .search-mini { flex: 0 1 360px; margin-inline: 0 auto; }
.topbar .brand + .search-mini { margin-inline-start: 0; }
.page-home .topbar .brand, .page-home .topbar .search-mini { display: none; }

/* ---------- shell: side rail (tablet) ---------- */
.rail {
  display: none; position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 20; width: var(--rail-w);
  padding: 16px 0 calc(20px + env(safe-area-inset-bottom)); background: var(--sunken);
  border-inline-end: 1px solid var(--rule); flex-direction: column; align-items: center; gap: 4px;
}
.rail .meem { margin-bottom: 12px; }
.rail-link {
  position: relative; width: var(--rail-w); height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--ink-2); text-decoration: none; font-size: 12px; line-height: 16px;
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.rail-link:hover { background: color-mix(in srgb, var(--rule) 45%, transparent); color: var(--ink); }
.rail-link[aria-current="page"] { color: var(--ink); font-weight: 600; }
.rail-link[aria-current="page"]::before {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--accent);
  transform-origin: top; animation: m-wipe-y var(--t-mid) var(--ease) both;
}
.rail-link[aria-current="page"] svg { color: var(--accent); }
.rail .spacer { flex: 1 1 auto; }

/* ---------- shell: search dock + tab bar (phone) ---------- */
.dock {
  display: none; position: fixed; inset-inline: 12px; z-index: 30;
  bottom: calc(var(--tabbar-h) + 8px + env(safe-area-inset-bottom));
  transition: transform var(--t-mid) var(--ease);
}
.dock-fade {
  display: none; position: fixed; inset-inline: 0; z-index: 25; pointer-events: none;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); height: 92px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--ground) 0%, transparent), var(--ground) 40px);
}
.tabbar {
  display: none; position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--sunken); border-top: 1px solid var(--rule);
  transition: transform var(--t-mid) var(--ease);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--ink-2); text-decoration: none; font-size: 12px; line-height: 16px;
}
.tab[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tab[aria-current="page"] svg { color: var(--accent); }
.tab[aria-current="page"]::before {
  content: ""; position: absolute; top: -1px; inset-inline: 22%; height: 2px; background: var(--accent);
  animation: m-wipe-x var(--t-mid) var(--ease) both;
}
body.bars-hidden .tabbar { transform: translateY(100%); }
body.bars-hidden .dock { transform: translateY(calc(var(--tabbar-h) + env(safe-area-inset-bottom))); }

/* ---------- search field ---------- */
.search-field {
  display: flex; align-items: center; gap: 12px; padding: 0 14px 0 18px; height: 52px;
  border: 1.5px solid var(--ink); border-radius: 14px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-1); outline: 1px solid var(--float-border); outline-offset: -1px;
  text-decoration: none; font-size: 16px;
  transition: box-shadow var(--t-mid) var(--ease), transform var(--t-fast) var(--ease);
}
.search-field:focus-within { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.search-field input {
  flex: 1 1 auto; min-width: 0; height: 44px; border: 0; background: transparent;
  font: inherit; color: var(--ink); outline: none;
}
.search-field input::placeholder, .search-field .placeholder { color: var(--ink-3); }
.search-field input::-webkit-search-cancel-button { display: none; }
.search-field kbd {
  flex: 0 0 auto; padding: 3px 8px; border: 1px solid var(--rule-strong); border-radius: var(--radius-2);
  font-family: inherit; font-size: 13px; line-height: 18px; color: var(--ink-2);
}
.search-field.big { height: 64px; border-radius: 18px; padding: 0 14px 0 22px; gap: 14px; font-size: 19px; }
.search-field.big input { height: 56px; }
.search-mini.search-field { height: 44px; border-radius: 10px; box-shadow: none; font-size: 15px; padding-inline: 14px 8px; }
.search-mini input { height: 40px; }

/* ---------- page frame ---------- */
#main { outline: none; }
.page { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 0 32px 48px; }
.page-title { font-size: var(--title-1-size); line-height: var(--title-1-lh); font-weight: 600; letter-spacing: -0.01em; }
.lead { font-size: var(--body-l-size); line-height: var(--body-l-lh); color: var(--ink-2); }
.muted { color: var(--ink-2); }
.meta { font-size: var(--meta-size); line-height: var(--meta-lh); color: var(--ink-3); }

/* ---------- lattice motif (headers and empty states only) ---------- */
.lattice {
  height: 38px; border-radius: 0; color: var(--rule-strong);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='38' height='38'%3E%3Cg fill='none' stroke='%23877F75' stroke-width='1'%3E%3Cpath stroke-opacity='.5' d='M12.35 12.35h13.3v13.3h-13.3z M19 9.6L28.4 19L19 28.4L9.6 19z'/%3E%3Cpath stroke-opacity='.3' d='M0 19h9.6M28.4 19h9.6'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 38px 38px;
}
[data-theme="night"] .lattice { opacity: .7; }

/* ---------- section header + file list ---------- */
.section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.home-lists .section-head { min-height: 56px; align-items: flex-end; padding-bottom: 4px; }
.section-head h2 { font-size: var(--title-2-size); line-height: var(--title-2-lh); font-weight: 600; letter-spacing: -0.01em; }
.section-head .sub { font-size: var(--small-size); line-height: var(--small-lh); color: var(--ink-2); }
.see-all {
  flex: 0 0 auto; min-height: 44px; display: inline-flex; align-items: center; gap: 2px; margin-inline-end: -8px; padding: 0 8px;
  font-size: 15px; line-height: 20px; font-weight: 500; color: var(--accent-text); text-decoration: none; border-radius: var(--radius-2);
}
.see-all:hover .chev { transform: translateX(calc(3px * var(--dir))); }
[dir="rtl"] .see-all:hover .chev { transform: scaleX(-1) translateX(3px); }
.see-all .chev { transition: transform var(--t-fast) var(--ease); }

.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border-top: 1px solid var(--rule); }
.row { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--rule); }
.row-link {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 16px; padding: 20px 0;
  color: var(--ink); text-decoration: none;
}
.row-link:hover .row-title { text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 4px; }
.row-rank { flex: 0 0 28px; font-size: 28px; line-height: 36px; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.row-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row-title { font-size: var(--body-l-size); line-height: var(--body-l-lh); font-weight: 500; overflow-wrap: anywhere; }
.row-meta { font-size: var(--small-size); line-height: var(--small-lh); color: var(--ink-2); }
.row-meta .code { font-size: 13px; }
.empty-line { padding: 20px 0; color: var(--ink-2); border-bottom: 1px solid var(--rule); }

/* skeleton rows while data loads */
.skel { display: block; flex: none; max-width: 100%; height: 14px; border-radius: 4px; background: var(--sunken); position: relative; overflow: hidden; }
/* Page skeletons (js/skeleton.js): shapes sized like what they stand in for. */
.skeleton .row-text, .skeleton .course-title, .skeleton .pane-head, .skeleton .file-text, .skeleton .choice-text { gap: 8px; }
.skeleton .page-head { gap: 12px; }
.skeleton .skel-row { pointer-events: none; }
.skeleton .course-link.skel-row { min-height: 64px; }
.skeleton .course-link .name { display: block; }
.skel-circle { width: 44px; height: 44px; border-radius: 50%; }
.skel-rank { display: flex; align-items: center; }
.skel-tabs { min-height: 48px; align-items: center; gap: 24px; }
.skel-field { display: flex; flex-direction: column; gap: 8px; }
.skel-input { height: 48px; border-radius: var(--radius-2); }
.skel-search { color: var(--ink-3); }
.skel-query { color: var(--ink); }
.skel-card { pointer-events: none; border-color: var(--rule); }
.skel-college { display: flex; flex-direction: column; gap: 8px; padding: 18px 0; border-bottom: 1px solid var(--rule); }
.skeleton .archive-pane { gap: 6px; }
.skeleton .pane-link { min-height: 32px; }
.skeleton .file-tools { gap: 8px; }
.skeleton .course-actions .skel { border-radius: var(--radius-2); }
.skeleton .file-icon { background: var(--sunken); }
.skeleton > * { animation: m-fade var(--t-mid) var(--ease) both; }
.skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent);
  animation: skel 1.2s var(--ease) infinite;
}
@keyframes skel { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }

/* ---------- footer ---------- */
.site-footer { display: flex; flex-direction: column; gap: 16px; }
.site-footer .wordmark { font-size: 20px; }
.site-footer p { font-size: 14px; line-height: 22px; color: var(--ink-2); }
.site-footer nav { display: flex; flex-wrap: wrap; column-gap: 20px; }
.site-footer nav a {
  min-height: 44px; display: inline-flex; align-items: center; font-size: 15px; line-height: 20px; color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 4px;
  transition: text-decoration-color var(--t-fast) var(--ease);
}
.site-footer nav a:hover { text-decoration-color: var(--accent); }
.site-footer .copy { font-size: 13px; line-height: 20px; color: var(--ink-3); }

/* ---------- Home ---------- */
.home-hero { padding: 72px 32px 0; display: flex; flex-direction: column; align-items: center; gap: 32px; text-align: center; }
.home-hero h1 { display: flex; font-size: 56px; line-height: 1.1; font-weight: 600; }
.home-hero h1 .wordmark { gap: 18px; }
.home-hero h1 .margin { height: 53px; }
/* Logo and description read as one group (16px apart); the search field sits clearly apart
   (40px), so the eye goes title → what to type → where to type it. */
.home-hero { gap: 40px; }
.home-intro { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.home-hero .hint { max-width: 42em; margin: 0; font-size: 18px; line-height: 28px; color: var(--ink-2); text-align: center; text-wrap: balance; }
.home-hero .hint .code { font-size: 17px; }
.home-hero form { width: 100%; max-width: 680px; }
.hero-search { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 40px; }
.home-lists {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr));
  gap: 48px 64px; align-items: start; padding-top: 64px;
}
.home-foot { display: flex; flex-direction: column; gap: 32px; padding-top: 56px; }

/* ---------- breakpoints ---------- */
@media (min-width: 720px) and (max-width: 1199px) {
  .rail { display: flex; }
  .topbar { display: none; }
  body { padding-inline-start: var(--rail-w); padding-top: 24px; }
  .home-hero { padding-top: 104px; }
}
@media (max-width: 719px) {
  body { padding-bottom: calc(var(--tabbar-h) + var(--dock-h) + 40px + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 14px 0 24px; padding-top: env(safe-area-inset-top); }
  .topbar .nav, .topbar .sep, .topbar .search-mini { display: none; }
  .page-home .topbar { justify-content: flex-end; }
  .tabbar { display: grid; }
  body.has-dock .dock, body.has-dock .dock-fade { display: block; }
  .page { padding: 0 24px 32px; }
  .home-lists { padding-top: 40px; gap: 56px; }
  .home-foot { padding-top: 32px; border-top: 1px solid var(--rule); gap: 16px; }
  .home-foot .lattice { display: none; }

  /* Phone Home: the search field sits in the dead centre of the screen area between the top
     bar and the tab bar. The wordmark and hint hang above it (absolutely positioned, so their
     height never moves the field) and the lists follow right below. The floating dock stays
     hidden while this field is on screen (js/views/home.js toggles .dock-on). */
  .home-hero { position: relative; display: flow-root; padding: 0 24px; } /* flow-root: the form's margin stays inside */
  .home-hero form {
    margin-top: max(176px, calc((100svh - 72px - var(--tabbar-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / 2 - 29px));
  }
  .home-intro { position: absolute; inset-inline: 24px; bottom: calc(58px + 32px); } /* field height + gap */
  /* The empty space above the wordmark holds the eight-point lattice motif, from the very top
     of the screen (behind the top bar) down to the title, where it fades out. js/views/home.js
     sets --pattern-top (how far the hero starts below the top of the page) and --pattern-h
     (space above the wordmark), so it never sits behind text. It fades in with the page. */
  .home-hero::before {
    content: ""; position: absolute; top: calc(-1 * var(--pattern-top, 0px)); inset-inline: 0; pointer-events: none;
    height: calc(var(--pattern-top, 0px) + var(--pattern-h, 0px));
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M13 13h14v14H13z M20 10.1L29.9 20L20 29.9L10.1 20z' fill='none' stroke='%23877F75' stroke-opacity='.45' stroke-width='1'/%3E%3C/svg%3E");
    background-size: 40px 40px; background-position: center bottom;
    -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 64px), transparent 100%);
    mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 64px), transparent 100%);
    animation: m-fade var(--t-slow) var(--ease) both;
  }
  [data-theme="night"] .home-hero::before { opacity: .75; }
  .page-home .topbar .icon-btn { background: var(--ground); } /* stay crisp on top of the pattern */
  .page-home .topbar .icon-btn:hover { background: var(--sunken); }
  .home-hero h1 { font-size: 44px; }
  .home-hero h1 .wordmark { gap: 14px; }
  .home-hero h1 .margin { height: 42px; }
  .home-intro { gap: 12px; }
  .home-hero .hint { max-width: 30em; font-size: 16px; line-height: 24px; }
  :root[lang="ar"] .home-hero .hint { line-height: 28px; }
  .home-hero kbd { display: none; }
  .home-hero .search-field.big { height: 58px; border-radius: 16px; font-size: 17px; padding: 0 16px 0 18px; }
  .home-hero .search-field.big input { height: 50px; }
  body.page-home .dock, body.page-home .dock-fade {
    opacity: 0; pointer-events: none; transform: translateY(12px);
    transition: opacity var(--t-mid) var(--ease), transform var(--t-mid) var(--ease);
  }
  body.page-home.dock-on .dock, body.page-home.dock-on .dock-fade { opacity: 1; pointer-events: auto; transform: none; }
  body.page-home.dock-on.bars-hidden .dock { transform: translateY(calc(var(--tabbar-h) + env(safe-area-inset-bottom))); }
}

/* =====================================================================================
   Milestone 2: course page, archive, saved, search, sheets
   ===================================================================================== */

/* ---------- shared bits ---------- */
.page.narrow { max-width: 760px; }
.page-head { display: flex; flex-direction: column; gap: 8px; padding: 32px 0 24px; }
.crumbs + .page-head { padding-top: 8px; }
.page-search .topbar .search-mini { visibility: hidden; } /* the page has its own field */
.btn-block { width: 100%; }
.stamp {
  display: inline-block; padding: 0 6px; border: 1px solid var(--ink); border-radius: var(--radius-1);
  font-size: var(--stamp-size); line-height: var(--stamp-lh); font-weight: 600; color: var(--ink); white-space: nowrap;
  vertical-align: 2px;
}
.pill {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; flex: 0 0 auto;
  font-size: var(--meta-size); line-height: var(--meta-lh); font-weight: 600;
}
.pill.new { background: var(--accent-tint); color: var(--accent-text); }
mark { background: var(--accent-tint); color: inherit; border-radius: 2px; padding: 0 1px; }

.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 16px 0 8px; font-size: var(--small-size); line-height: var(--small-lh); }
.crumbs a { min-height: 32px; display: inline-flex; align-items: center; flex: 0 0 auto; color: var(--ink-2); text-decoration: none; border-radius: var(--radius-1); white-space: nowrap; }
.crumbs a:last-of-type { flex: 0 1 auto; min-width: 0; display: block; line-height: 32px; overflow: hidden; text-overflow: ellipsis; }
.crumbs .chev { flex: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.crumbs .chev { color: var(--ink-3); }

/* course rows: code · name · count (department, saved, search, desktop middle pane) */
.course-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.course-link {
  min-height: 64px; display: flex; align-items: center; gap: 14px; padding: 10px 0;
  color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); border-radius: 0;
  transition: background-color var(--t-fast) var(--ease);
}
.course-list li:last-child .course-link { border-bottom-color: var(--rule); }
.course-link:hover { background: color-mix(in srgb, var(--sunken) 70%, transparent); }
.course-link .code { flex: 0 0 auto; min-width: 76px; font-size: 14px; }
.course-link .name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.course-link .n, .course-link .meta { flex: 0 0 auto; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.course-link .chev { color: var(--ink-3); }
.course-link[aria-current="page"], .course-link.best { background: var(--accent-tint); margin-inline: -12px; padding-inline: 12px; }
.course-list.big .course-link { min-height: 68px; }

/* empty and not-found states */
.empty-state { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding: 32px 0; max-width: 560px; }
.empty-state .lattice { width: 100%; margin-bottom: 8px; }
.empty-state h1, .empty-state h2 { font-size: var(--title-2-size); line-height: var(--title-2-lh); font-weight: 600; }
.empty-state .btn-block + .btn-block { margin-top: -4px; }
.note-box {
  display: flex; flex-direction: column; gap: 4px; margin-top: 32px; padding: 16px 20px;
  background: var(--sunken); border-radius: var(--radius-3); font-size: var(--small-size); line-height: var(--small-lh); color: var(--ink-2);
}
.note-box strong { color: var(--ink); font-weight: 600; }

/* ---------- course page ---------- */
.course-layout { display: grid; grid-template-columns: 1fr; min-height: calc(100vh - 72px); }
.pane { display: none; }
.course-main { min-width: 0; padding: 0 32px 48px; max-width: 920px; width: 100%; }
.course-head { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; padding: 8px 0 24px; }
.course-title { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.course-title > .code { font-size: 15px; color: var(--accent-text); }
.course-title h1 { font-size: var(--title-1-size); line-height: var(--title-1-lh); font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
.course-title .meta { font-size: var(--small-size); line-height: var(--small-lh); color: var(--ink-2); }
.course-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.course-actions [aria-pressed="true"] svg { color: var(--accent); }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--rule); margin-inline: -4px; padding-inline: 4px; }
.tab-btn {
  position: relative; flex: 0 0 auto; min-height: 48px; padding: 0 12px; border: 0; background: none; cursor: pointer;
  font-size: 15px; line-height: 20px; color: var(--ink-2); border-radius: var(--radius-2) var(--radius-2) 0 0;
}
.tab-btn .count { color: var(--ink-3); font-variant-numeric: tabular-nums; margin-inline-start: 2px; }
.tab-btn:hover { color: var(--ink); background: color-mix(in srgb, var(--sunken) 60%, transparent); }
.tab-btn[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.tab-btn[aria-selected="true"]::after {
  content: ""; position: absolute; inset-inline: 12px; bottom: -1px; height: 2px; background: var(--accent);
  animation: m-wipe-x var(--t-mid) var(--ease) both;
}
.years { display: inline-flex; flex-wrap: wrap; gap: 0; margin-top: 16px; border: 1px solid var(--rule-strong); border-radius: var(--radius-2); overflow: hidden; }
.seg-btn {
  min-height: 40px; padding: 0 14px; border: 0; background: none; cursor: pointer; font-size: 14px; color: var(--ink-2);
  font-variant-numeric: tabular-nums; transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg-btn + .seg-btn { border-inline-start: 1px solid var(--rule); }
.seg-btn:hover { background: var(--sunken); }
.seg-btn[aria-checked="true"] { background: var(--ink); color: var(--ground); font-weight: 600; }

.file-list { list-style: none; margin: 0; padding: 0; }
.years:not([hidden]) + .file-list { margin-top: 16px; border-top: 1px solid var(--rule); }
.file-row { display: flex; align-items: center; gap: 16px; min-height: 80px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.file-icon {
  flex: 0 0 44px; height: 44px; border-radius: var(--radius-2); background: var(--sunken); color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
}
.file-main { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.file-main:hover .file-title > span:first-child { text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 4px; }
.file-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.file-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; font-size: 17px; line-height: 24px; font-weight: 600; overflow-wrap: anywhere; }
.file-meta { font-size: var(--small-size); line-height: var(--small-lh); color: var(--ink-2); }
.file-dl-icon { display: none; }
.file-tools { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; }
.file-tools .dl { margin-inline-start: 8px; }
.file-row .more { display: none; }
.helpful-pill {
  min-height: 36px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--rule-strong); background: none; color: var(--ink-2); font-size: 14px; line-height: 20px; font-variant-numeric: tabular-nums;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.helpful-pill:hover { background: var(--sunken); color: var(--ink); }
.helpful-pill[aria-pressed="true"] { background: var(--accent-tint); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

/* desktop panes */
.pane-head { display: flex; flex-direction: column; gap: 2px; padding: 28px 24px 16px; }
.pane-head h2 { font-size: var(--title-3-size); line-height: var(--title-3-lh); font-weight: 600; }
.dept-pane .course-list { border-top: 1px solid var(--rule); }
.dept-pane .course-link { margin: 0; padding-inline: 24px; gap: 12px; }
.dept-pane .course-link .code { min-width: 72px; font-size: 13px; }
.dept-pane .course-link .name { font-size: 15px; line-height: 20px; }
.archive-pane { flex-direction: column; gap: 2px; padding: 24px 12px; background: var(--sunken); border-inline-end: 1px solid var(--rule); }
.pane-label { padding: 16px 12px 8px; font-size: var(--meta-size); line-height: var(--meta-lh); font-weight: 600; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }
.pane-label:first-child { padding-top: 0; }
.pane-college summary {
  list-style: none; min-height: 40px; display: flex; align-items: center; padding: 0 12px; border-radius: var(--radius-2);
  cursor: pointer; font-size: 15px; font-weight: 500;
}
.pane-college summary::-webkit-details-marker { display: none; }
.pane-college summary:hover, .pane-link:hover { background: color-mix(in srgb, var(--rule) 45%, transparent); }
.pane-link {
  min-height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-radius: var(--radius-2);
  color: var(--ink-2); text-decoration: none; font-size: 14px; line-height: 20px;
}
.pane-college .pane-link { padding-inline-start: 24px; }
.pane-link > span:first-child, .pane-link .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-link .n { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pane-link .code { font-size: 13px; }
.pane-link[aria-current] { background: var(--accent-tint); color: var(--ink); font-weight: 600; }
.pane-link.about { margin-top: 16px; }

@media (min-width: 720px) {
  .page-course .crumbs { display: none; }
  .course-layout { grid-template-columns: 300px minmax(0, 1fr); }
  .dept-pane { display: block; border-inline-end: 1px solid var(--rule); }
  .course-main { padding-top: 28px; }
}
@media (min-width: 1200px) {
  .course-layout { grid-template-columns: 264px 300px minmax(0, 1fr); border-top: 1px solid var(--rule); }
  .archive-pane { display: flex; }
  .dept-pane, .archive-pane { position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; }
}
@media (max-width: 1199px) { .course-title .place { display: none; } }
@media (max-width: 719px) {
  .course-main { padding: 0 24px 24px; }
  .course-head { padding-bottom: 20px; }
  .course-title h1 { font-size: var(--title-2-size); line-height: var(--title-2-lh); }
  .course-actions { width: 100%; flex-wrap: nowrap; }
  .course-actions .btn { padding: 0 12px; }
  .course-actions .add-file { flex: 1 1 auto; }
  .course-actions .btn-ghost { border-color: var(--rule-strong); }
  .file-row { min-height: 76px; gap: 4px; padding: 8px 0; }
  .file-icon, .file-tools { display: none; }
  .file-main { padding: 6px 0; }
  .file-dl-icon { display: flex; flex: 0 0 auto; color: var(--ink-2); }
  .file-title { font-size: 16px; }
  .file-row .more { display: inline-flex; margin-inline-end: -10px; }
}

/* the docked back button (phones), beside the search field */
@media (max-width: 719px) { body.has-dock .dock:has(.dock-back) { display: flex; gap: 8px; } }
.dock .search-field { flex: 1 1 auto; }
.dock-back {
  flex: 0 0 52px; height: 52px; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--ink); border-radius: 14px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-1); outline: 1px solid var(--float-border); outline-offset: -1px;
}

/* ---------- archive ---------- */
.college-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.college { border-bottom: 1px solid var(--rule); }
.college summary {
  list-style: none; min-height: 72px; display: flex; align-items: center; gap: 12px; padding: 12px 0; cursor: pointer;
}
.college summary::-webkit-details-marker { display: none; }
.college-text { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.college-name { font-size: var(--body-l-size); line-height: var(--body-l-lh); font-weight: 600; }
.disclosure { display: flex; color: var(--ink-3); transition: transform var(--t-mid) var(--ease); transform: rotate(90deg); }
.college[open] .disclosure { transform: rotate(-90deg); }
[dir="rtl"] .disclosure .chev { transform: none; } /* up/down needs no mirroring */
.dept-list { list-style: none; margin: 0 0 12px; padding: 0; animation: m-fade-up var(--t-mid) var(--ease) both; }
.dept-link {
  min-height: 56px; display: flex; align-items: center; gap: 12px; padding: 8px 12px; margin-inline: -12px; border-radius: var(--radius-2);
  color: var(--ink); text-decoration: none;
}
.dept-link > span:first-child { flex: 1 1 auto; min-width: 0; }
.dept-link .meta, .course-link .meta, .course-link .n { white-space: nowrap; }
.dept-link:hover { background: var(--sunken); }
.dept-link .chev { color: var(--ink-3); }

/* ---------- search ---------- */
.search-page { padding-top: 32px; }
.search-box { display: flex; align-items: center; gap: 12px; }
.search-box .search-field { flex: 1 1 auto; }
.search-box .clear { margin-inline-end: -6px; }
.search-box .cancel { display: none; min-height: 44px; align-items: center; padding: 0 4px; color: var(--accent-text); text-decoration: none; font-weight: 500; }
.results { padding-top: 24px; display: flex; flex-direction: column; gap: 32px; }
.result-count { margin-bottom: -16px; }
.result-group { display: flex; flex-direction: column; gap: 12px; }
.group-label { font-size: var(--meta-size); line-height: var(--meta-lh); font-weight: 600; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }
.row.best { background: var(--accent-tint); margin-inline: -12px; padding-inline: 12px; border-radius: var(--radius-2); }
.best-label { color: var(--accent-text); font-weight: 600; }
.search-hint { color: var(--ink-2); }
.result-group .page-title { margin-bottom: 8px; }
@media (max-width: 719px) {
  .search-page { padding-top: 12px; }
  .search-box .cancel { display: inline-flex; }
  .search-box .search-field.big { height: 52px; border-radius: 14px; font-size: 16px; padding: 0 8px 0 16px; }
  .search-box .search-field.big input { height: 44px; }
}

/* ---------- sheets (<dialog>) ---------- */
body.sheet-open { overflow: hidden; }
dialog.sheet {
  width: min(440px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 32px)); padding: 24px; margin: auto;
  border: 1px solid var(--float-border); border-radius: var(--radius-3); background: var(--surface); color: var(--ink);
  box-shadow: 0 12px 40px rgb(29 24 20 / .18); overflow-y: auto;
  animation: m-pop var(--t-mid) var(--ease) both;
}
dialog.sheet::backdrop { background: var(--scrim); animation: m-fade var(--t-mid) var(--ease) both; }
dialog.sheet.closing, dialog.sheet.closing::backdrop { animation: m-fade var(--t-mid) var(--ease) reverse both; }
.sheet-grip { display: none; }
.sheet-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.sheet-head h2 { font-size: var(--title-3-size); line-height: var(--title-3-lh); font-weight: 600; overflow-wrap: anywhere; }
.sheet .sub { font-size: var(--small-size); line-height: var(--small-lh); color: var(--ink-2); }
.sheet-list { display: flex; flex-direction: column; margin: 0 -12px; }
.sheet-row {
  min-height: 60px; display: flex; align-items: center; gap: 16px; padding: 8px 12px; border: 0; border-radius: var(--radius-2);
  background: none; color: var(--ink); text-align: start; text-decoration: none; cursor: pointer; font-size: 16px;
}
.sheet-row:hover { background: var(--sunken); }
.sheet-row > svg { color: var(--ink-2); }
.sheet-row-text { flex: 1 1 auto; display: flex; flex-direction: column; }
.sheet-row .check { display: none; color: var(--accent); }
.sheet-row[aria-pressed="true"] .check { display: flex; }
.sheet-row[aria-pressed="true"] > svg { color: var(--accent); }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.share-preview { padding: 16px; border-radius: var(--radius-2); background: var(--sunken); display: flex; flex-direction: column; gap: 6px; font-size: 15px; line-height: 22px; }
.share-preview [lang="ar"] { line-height: 26px; }
.share-url { color: var(--accent-text); font-size: 14px; }
.choices { border: 0; margin: 0 -12px; padding: 0; display: flex; flex-direction: column; }
.choice { min-height: 52px; display: flex; align-items: center; gap: 14px; padding: 0 12px; border-radius: var(--radius-2); cursor: pointer; }
.choice:hover { background: var(--sunken); }
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.field { display: block; margin-top: 12px; }
.field textarea {
  width: 100%; min-height: 88px; padding: 12px 14px; border: 1px solid var(--rule-strong); border-radius: var(--radius-2);
  background: var(--ground); color: var(--ink); font: inherit; resize: vertical;
}
.field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-error { margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-2); background: var(--danger-tint); color: var(--danger); font-size: var(--small-size); }
@media (max-width: 719px) {
  dialog.sheet {
    width: 100%; max-width: none; max-height: calc(100svh - 48px); margin: auto 0 0; padding: 8px 24px calc(20px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0; border-bottom: 0; animation: m-slide-up var(--t-slow) var(--ease) both;
  }
  dialog.sheet.closing { animation: m-slide-up var(--t-mid) var(--ease) reverse both; }
  .sheet-grip { display: block; width: 36px; height: 4px; margin: 0 auto 16px; border-radius: 2px; background: var(--rule-strong); }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 60; inset-inline: 0; bottom: 24px; width: max-content; max-width: calc(100vw - 32px); margin: 0 auto;
  padding: 12px 18px; border-radius: var(--radius-3); background: var(--ink); color: var(--ground);
  font-size: 15px; line-height: 20px; opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity var(--t-mid) var(--ease), transform var(--t-mid) var(--ease);
}
.toast[data-tone="danger"] { background: var(--danger); color: var(--surface); }
.toast.show { opacity: 1; transform: none; }
@media (max-width: 719px) { .toast { bottom: calc(var(--tabbar-h) + var(--dock-h) + 24px + env(safe-area-inset-bottom)); } }

/* =====================================================================================
   Milestone 3: contribute, share a file, request a course, about
   ===================================================================================== */

/* ---------- contribute ---------- */
.choice-cards { display: flex; flex-direction: column; gap: 12px; }
.choice-card {
  display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: var(--radius-3);
  background: var(--surface); border: 1.5px solid var(--ink); color: var(--ink); text-decoration: none;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-mid) var(--ease);
}
.choice-card:hover { box-shadow: var(--shadow-1), 0 6px 20px rgb(29 24 20 / .08); }
.choice-card:active { transform: scale(.99); }
.choice-card > .chev { color: var(--ink-3); transition: transform var(--t-fast) var(--ease); }
.choice-card:hover > .chev { transform: translateX(3px); }
[dir="rtl"] .choice-card:hover > .chev { transform: scaleX(-1) translateX(3px); }
.choice-icon { flex: 0 0 44px; height: 44px; border-radius: 8px; background: var(--sunken); display: flex; align-items: center; justify-content: center; }
.choice-text { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; font-size: var(--small-size); line-height: var(--small-lh); }
.choice-title { font-size: 17px; line-height: 24px; font-weight: 600; }
.rules { margin-top: 32px; display: flex; flex-direction: column; gap: 8px; }
.rules h2, .about-sections h2 { font-size: 16px; line-height: 24px; font-weight: 600; }
.rules ul, .about-sections ul { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 4px; color: var(--ink-2); }
.rules li::marker, .about-sections li::marker { color: var(--accent); }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 20px; }
.form-section { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.form-section .details-label { margin-top: 12px; }
.form .field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.form .label { font-size: var(--small-size); line-height: var(--small-lh); font-weight: 500; }
.form input:not([type=file]):not([type=radio]):not([type=checkbox]), .form select {
  width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--rule-strong); border-radius: var(--radius-2);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px;
  transition: border-color var(--t-fast) var(--ease);
}
.form select { appearance: none; padding-inline-end: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23877F75' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
[dir="rtl"] .form select { background-position: left 14px center; }
.form select:disabled { opacity: .55; cursor: not-allowed; }
.form input:focus, .form select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--ink); }
.form input::placeholder { color: var(--ink-3); }
.field-row { display: flex; flex-wrap: wrap; gap: 12px; }
.field-row .field { flex: 1 1 140px; }
.field-row .code-field { flex: 0 1 150px; }
.field-row .year-field { flex: 0 1 110px; }
.field-row .grow { flex: 1 1 160px; }
.field-hint { min-height: 20px; margin-top: -8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--small-size); line-height: var(--small-lh); color: var(--ink-2); }
.field-hint[data-tone="ok"] { flex-wrap: nowrap; align-items: flex-start; }
.field-hint[data-tone="ok"] svg { flex: none; margin-top: 2px; color: var(--success); }
.field-hint[data-tone="ok"] > span { flex: 1 1 auto; min-width: 0; }
.field-hint[data-tone="warn"] { color: var(--warning); }
.field-hint a { font-weight: 500; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }
.form-actions.start { justify-content: flex-start; flex-wrap: wrap; }
.form-actions .btn-primary { min-width: 160px; }
.form-actions .btn-primary:disabled { opacity: .7; cursor: progress; }
.form .form-error { margin: 0; }
.form .form-error a { color: inherit; font-weight: 600; }
.text-btn { align-self: flex-start; min-height: 40px; padding: 0; border: 0; background: none; color: var(--accent-text); font-size: 15px; font-weight: 500; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }

/* drop zone and upload progress */
.dropzone {
  display: flex; flex-direction: column; align-items: flex-start; gap: 14px; padding: 20px; border-radius: var(--radius-3);
  border: 1.5px dashed var(--rule-strong); background: var(--surface);
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.dropzone.over { border-color: var(--accent); background: var(--accent-tint); }
.drop-icon { width: 44px; height: 44px; border-radius: 8px; background: var(--sunken); display: flex; align-items: center; justify-content: center; }
.drop-text { display: flex; flex-direction: column; gap: 2px; }
.drop-text strong { font-weight: 500; font-size: 16px; }
.drop-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.drop-buttons label { cursor: pointer; }
.drop-buttons label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.upload-card {
  display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: var(--radius-3);
  border: 1px solid var(--rule); background: var(--surface); animation: m-fade-up var(--t-mid) var(--ease) both;
}
.upload-head { display: flex; align-items: center; gap: 8px; }
.upload-name { flex: 1 1 auto; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.upload-head .icon-btn { margin: -8px -10px -8px 0; }
.bar { display: block; height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 3px; transition: width var(--t-slow) var(--ease); }
.upload-card.done .bar > span { background: var(--success); }
.upload-card.done [data-note] { display: none; }
.upload-card.failed .bar { display: none; }
.upload-card.failed [data-status] { color: var(--danger); font-size: var(--small-size); }
.upload-card.failed [data-note] { display: none; }

@media (min-width: 1000px) {
  .submit-page { max-width: 1040px; }
  .form-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; }
}
@media (max-width: 999px) { .form-cols { display: flex; flex-direction: column; gap: 28px; } }
@media (max-width: 719px) {
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}

/* sent confirmation */
.sent { display: flex; flex-direction: column; gap: 16px; padding-top: 24px; }
.sent .lattice { margin-bottom: 8px; }
.sent h1:focus { outline: none; }
.summary { margin: 8px 0 0; border-top: 1px solid var(--rule); }
.summary > div { display: flex; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.summary dt { flex: 0 0 88px; color: var(--ink-3); font-size: var(--small-size); }
.summary dd { margin: 0; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

/* ---------- about ---------- */
.about .lead { max-width: 60ch; }
.about-sections { display: flex; flex-direction: column; gap: 28px; margin-top: 36px; }
.about-sections section { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding-top: 20px; border-top: 1px solid var(--rule); }
.more-fields { border-top: 1px solid var(--rule); padding-top: 4px; }
.more-fields summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--accent-text); font-weight: 500; list-style: none; }
.more-fields summary::-webkit-details-marker { display: none; }
.more-fields summary::before { content: "+"; width: 20px; font-size: 18px; }
.more-fields[open] summary::before { content: "−"; }
.more-fields[open] > :not(summary) { animation: m-fade-up var(--t-mid) var(--ease) both; }
.more-fields .field + .field { margin-top: 14px; }
.more-fields .meta { margin-top: 6px; }
.form textarea {
  width: 100%; min-height: 88px; padding: 12px 14px; border: 1px solid var(--rule-strong); border-radius: var(--radius-2);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; resize: vertical;
}
.form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--ink); }

/* ---------- results under a search field as you type (js/typeahead.js) ---------- */
[data-search-form] { position: relative; }
.typeahead {
  position: absolute; z-index: 40; top: calc(100% + 8px); inset-inline: 0;
  max-height: min(70vh, 520px); overflow-y: auto; padding: 6px; border-radius: 14px; text-align: start;
  background: var(--surface); border: 1px solid var(--rule); box-shadow: 0 12px 32px rgb(29 24 20 / .14);
  outline: 1px solid var(--float-border); outline-offset: -1px; animation: m-fade-up var(--t-fast) var(--ease) both;
}
.ta-label { padding: 10px 10px 4px; font-size: var(--meta-size); line-height: var(--meta-lh); font-weight: 600; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }
.ta-option {
  min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-2);
  color: var(--ink); text-decoration: none; font-size: 15px; line-height: 20px;
}
.ta-option .code { flex: none; font-size: 13px; }
.ta-option .ta-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.ta-option .meta { flex: none; white-space: nowrap; }
.ta-option:hover, .ta-option[aria-selected="true"] { background: var(--sunken); }
.ta-all { margin-top: 4px; border-top: 1px solid var(--rule); border-radius: 0 0 var(--radius-2) var(--radius-2); color: var(--accent-text); font-weight: 500; }
.ta-empty { padding: 12px 10px 6px; color: var(--ink-2); font-size: 15px; }
.home-hero .typeahead { box-shadow: 0 16px 40px rgb(29 24 20 / .16); }
@media (min-width: 720px) { .search-mini .typeahead { min-width: 460px; } } /* the top-bar field is narrow */

/* ---------- college filter under Home's search (js/collegePicker.js) ---------- */
.pickers { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: -24px; } /* 16px under the field */
.college-picker { position: relative; display: flex; justify-content: center; }
.cp-button {
  min-height: 44px; display: inline-flex; align-items: center; gap: 8px; padding: 0 14px 0 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 15px;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.cp-icon { display: flex; flex: none; color: var(--accent-text); }
.cp-button:hover { background: var(--sunken); }
.cp-button[aria-expanded="true"] { border-color: var(--accent); }
.cp-caret { display: flex; color: var(--ink-3); transform: rotate(90deg); transition: transform var(--t-mid) var(--ease); }
.cp-button[aria-expanded="true"] .cp-caret { transform: rotate(-90deg); }
.cp-list {
  position: absolute; z-index: 45; top: calc(100% + 6px); left: 50%; translate: -50% 0; /* not transform: the fade-in animates it */
  width: max-content; min-width: 260px; max-width: calc(100vw - 32px); max-height: 360px; overflow-y: auto;
  margin: 0; padding: 6px; list-style: none; text-align: start; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--rule); box-shadow: 0 12px 32px rgb(29 24 20 / .14);
  outline: 1px solid var(--float-border); outline-offset: -1px; animation: m-fade-up var(--t-fast) var(--ease) both;
}
.cp-list:focus { outline-color: var(--float-border); }
.cp-list [role="option"] {
  min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  border-radius: var(--radius-2); cursor: pointer; font-size: 15px;
}
.cp-list [role="option"].active, .cp-list [role="option"]:hover { background: var(--sunken); }
.cp-list [role="option"][aria-selected="true"] { font-weight: 600; }
.cp-name { flex: 1 1 auto; }
.cp-check { display: flex; color: var(--accent); visibility: hidden; margin-inline-start: 8px; }
.cp-list [aria-selected="true"] .cp-check { visibility: visible; }
.cp-skel { width: 168px; height: 44px; border-radius: 999px; }
.filter-note { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 16px; padding: 10px 14px; border-radius: var(--radius-2); background: var(--accent-tint); color: var(--ink); font-size: var(--small-size); }
@media (max-width: 719px) {
  .pickers { margin-top: 16px; }
  /* The wordmark and hint hang 32px above the field itself, whatever sits below it. */
  .hero-search { display: block; position: relative; margin-top: max(176px, calc((100svh - 72px - var(--tabbar-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / 2 - 29px)); }
  .home-hero .hero-search form { margin-top: 0; }
  .home-intro { inset-inline: 0; bottom: calc(100% + 32px); }
}

/* ---------- custom dropdowns in place of <select> (js/dropdown.js) ---------- */
.dd { position: relative; width: 100%; }
.dd-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; } /* kept for forms and validation */
.dd-button {
  width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 0 12px 0 14px; border: 1px solid var(--rule-strong); border-radius: var(--radius-2); cursor: pointer;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; text-align: start;
  transition: border-color var(--t-fast) var(--ease);
}
.dd-button.placeholder .dd-value { color: var(--ink-3); }
.dd-button:hover { border-color: var(--ink-2); }
.dd-button[aria-expanded="true"], .dd-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--ink); }
.dd-button:disabled { opacity: .55; cursor: not-allowed; }
.dd-value { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-caret { display: flex; color: var(--ink-3); transform: rotate(90deg); transition: transform var(--t-mid) var(--ease); }
.dd-button[aria-expanded="true"] .dd-caret { transform: rotate(-90deg); }
.dd-list {
  position: absolute; z-index: 50; top: calc(100% + 4px); inset-inline-start: 0; min-width: 100%; width: max-content; max-width: min(420px, calc(100vw - 32px));
  max-height: 300px; overflow-y: auto; margin: 0; padding: 6px; list-style: none; border-radius: var(--radius-3);
  background: var(--surface); border: 1px solid var(--rule); box-shadow: 0 12px 32px rgb(29 24 20 / .14);
  outline: 1px solid var(--float-border); outline-offset: -1px; animation: m-fade-up var(--t-fast) var(--ease) both;
}
.dd-list [role="option"] { min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--radius-2); cursor: pointer; font-size: 15px; }
.dd-list [role="option"].active, .dd-list [role="option"]:hover { background: var(--sunken); }
.dd-list [role="option"][aria-selected="true"] { font-weight: 600; }
.dd-list [aria-disabled="true"] { opacity: .5; cursor: default; }
.dd-name { flex: 1 1 auto; }
.dd-check { display: flex; color: var(--accent); visibility: hidden; }
.dd-list [aria-selected="true"] .dd-check { visibility: visible; }
