/* SiteAim Portal
   Colour tokens and their contrast reasoning are carried over from
   siteaim.com/styles.css so the portal reads as the same product.
   Layout: white sidebar, flat bordered panels, no shadows. */

:root {
  /* Brand orange. Borders, focus rings, marks. */
  --orange: #f35b05;
  /* Orange for text on white and on the peach tints (clears AA). */
  --orange-dark: #b03e08;
  /* Filled-button orange: white labels need this to clear AA. */
  --orange-btn: #c74600;
  --orange-btn-dark: #a83a00;
  /* Lifted orange, for text and marks on the dark purple. */
  --orange-lit: #ff8f4d;

  --ink: #0d1526;
  --slate: #4a5769;
  --line: #e4e8ee;

  --purple: #1c1740;
  --purple-mid: #2e2766;
  --purple-deep: #14102b;
  --lilac: #b3aae8;
  --lilac-pale: #ece9fb;

  --peach: #fdece2;
  --peach-pale: #fff1e6;

  --page: #f6f5f9;
  --card: #ffffff;

  --ok: #0f7a4d;
  --ok-bg: #e7f6ee;
  --warn: #8a5300;
  --warn-bg: #fdf1dc;
  --err: #b3261e;
  --err-bg: #fdecea;

  --radius: 6px;
  --sidebar: 15rem;
  /* How wide the content area is allowed to run before it stops
     stretching. Generous, since most screens here are tables and forms
     rather than prose. */
  --wrap-max: 100rem;

  --font-display: "Familjen Grotesk", -apple-system, BlinkMacSystemFont,
                  "Segoe UI", Arial, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin: 0;
}

a { color: var(--orange-dark); }
a:hover { color: var(--orange-btn-dark); }

:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Visible only to screen readers. */
.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;
}

/* ---------- Auth screens ---------- */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth__aside {
  background: linear-gradient(160deg, var(--purple) 0%, var(--purple-deep) 100%);
  color: #fff;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.auth__aside h2 {
  font-size: 2rem;
  margin-top: 2.5rem;
  max-width: 20ch;
}

.auth__aside p {
  color: var(--lilac);
  max-width: 38ch;
}

.auth__points {
  list-style: none;
  padding: 0;
  margin: 2rem 0 0;
}

.auth__points li {
  padding-left: 1.6rem;
  position: relative;
  margin-bottom: .6rem;
  color: var(--lilac-pale);
}

.auth__points li::before {
  content: "";
  position: absolute;
  left: 0; top: .55em;
  width: .5rem; height: .5rem;
  border-radius: 50%;
  background: var(--orange-lit);
}

.auth__aside footer { color: #8d84c4; font-size: .82rem; }

.auth__main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  background: #fff;
}

.auth__card { width: 100%; max-width: 25rem; }
.auth__card h1 { font-size: 1.7rem; margin-bottom: .4rem; }
.auth__card .lede { color: var(--slate); margin: 0 0 1.75rem; }

.logo { height: 30px; width: auto; display: block; }

/* ---------- Forms ---------- */

.field { margin-bottom: .85rem; }

.field label {
  display: block;
  font-weight: 600;
  font-size: .85rem;
  margin-bottom: .25rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: .5rem .7rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.field textarea { resize: vertical; min-height: 6rem; }
.field select { appearance: auto; }

.field input:focus-visible,
.field textarea:focus-visible,
.field select:focus-visible { border-color: var(--orange); outline-offset: 0; }

.field .hint { font-size: .8rem; color: var(--slate); margin-top: .3rem; }

.field--inline { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; }
.field--inline > * { flex: 1; min-width: 10rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .65rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--orange-btn);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease;
  white-space: nowrap;
}

.btn:hover { background: var(--orange-btn-dark); color: #fff; }
.btn--block { width: 100%; }

.btn--ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.btn--ghost:hover { background: var(--page); color: var(--ink); }

.btn--danger { background: #fff; color: var(--err); border-color: #f2c6c2; }
.btn--danger:hover { background: var(--err-bg); color: var(--err); }

.btn--sm { padding: .35rem .7rem; font-size: .85rem; }

.form-foot {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  font-size: .9rem;
  color: var(--slate);
}

/* ---------- Alerts ---------- */

.alert {
  padding: .75rem .9rem;
  border-radius: var(--radius);
  margin-bottom: 1.1rem;
  font-size: .9rem;
  border: 1px solid transparent;
}

.alert--error   { background: var(--err-bg); color: var(--err); border-color: #f2c6c2; }
.alert--success { background: var(--ok-bg);  color: var(--ok);  border-color: #b8e2cc; }
.alert--info    { background: var(--peach-pale); color: var(--orange-dark); border-color: #ffd9bd; }

/* ---------- Impersonation banner ---------- */

.impersonating {
  grid-column: 1 / -1;
  background: var(--orange);
  color: #1a1005;
  padding: .55rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: .9rem;
}
.impersonating .btn { background: #1a1005; color: #fff; }
.impersonating .btn:hover { background: #000; }

/* ---------- App shell: sidebar + content ---------- */

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  grid-template-rows: auto 1fr;
}

/* Dark sidebar on the brand purple, matching the sign-in panel. */
.sidebar {
  grid-row: 2;
  background: var(--purple);
  color: #fff;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .25rem .75rem 1.5rem;
}

.sidebar__group {
  margin: 1.1rem .75rem .35rem;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #8d84c4;
}

.sidebar a.nav {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .75rem;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
  color: var(--lilac-pale);
  text-decoration: none;
  font-weight: 500;
  font-size: .95rem;
}

.sidebar a.nav:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.sidebar a.nav[aria-current="page"] {
  background: rgba(255, 255, 255, .12);
  border-left-color: var(--orange-lit);
  font-weight: 600;
  color: #fff;
}

/* Icons sit a shade dimmer than the label until the item is current. */
.sidebar a.nav .icon { flex: 0 0 auto; opacity: .7; }
.sidebar a.nav:hover .icon,
.sidebar a.nav[aria-current="page"] .icon { opacity: 1; }
.sidebar a.nav[aria-current="page"] .icon { color: var(--orange-lit); }
.sidebar a.nav > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar a.nav .count {
  margin-left: auto;
  background: var(--orange-lit);
  color: #1a1005;
  font-size: .72rem;
  font-weight: 700;
  padding: .05rem .45rem;
  border-radius: 999px;
}

/* One row: the person block left, sign-out right - nothing to fall off
   the bottom on short screens. */
.sidebar__foot {
  margin-top: auto;
  padding: .9rem .25rem 0;
  border-top: 1px solid rgba(255, 255, 255, .14);
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

/* The person block is the way to the account page for both roles. */
.sidebar__user {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .4rem .5rem;
  min-width: 0;
  border-radius: var(--radius);
  color: #fff;
  text-decoration: none;
  line-height: 1.25;
}
.sidebar__user > span { min-width: 0; }
.sidebar__user .who,
.sidebar__user .role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__user:hover,
.sidebar__user[aria-current="page"] { background: rgba(255, 255, 255, .1); color: #fff; }

.avatar {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--orange-lit);
  color: #1a1005;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .85rem;
  letter-spacing: .02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* A square box whatever the photo's shape, cropped rather than squashed. */
  aspect-ratio: 1 / 1;
}

.avatar--photo {
  object-fit: cover;
  object-position: center;
  background: var(--page);
  /* A hairline keeps a pale photo from bleeding into a pale panel. */
  box-shadow: inset 0 0 0 1px rgba(13, 21, 38, .08);
}

.avatar--lg { width: 4.5rem; height: 4.5rem; font-size: 1.4rem; }

/* Name and face together, in a table cell or a list. */
.person { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; }
.person > span:last-child { overflow: hidden; text-overflow: ellipsis; }

/* Upload control: the current photo beside its controls, stacking when
   there is no room for both. */
.photo-form { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.photo-form__controls { flex: 1 1 14rem; min-width: 0; }
.photo-form__controls .field { margin-bottom: .6rem; }
.photo-form input[type="file"] { max-width: 100%; }

.sidebar__foot .who { font-weight: 600; display: block; color: #fff; }
.sidebar__foot .role { color: var(--lilac); font-size: .78rem; display: block; }

.sidebar__foot .signout {
  flex: 0 0 auto;
  color: var(--lilac);
  font-weight: 600;
  font-size: .8rem;
  text-decoration: none;
  padding: .35rem .5rem;
  border-radius: var(--radius);
}
.sidebar__foot .signout:hover { color: #fff; background: rgba(255, 255, 255, .1); }

.tag {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: .12rem .45rem;
  border-radius: 4px;
  background: var(--orange-lit);
  color: #1a1005;
}

.main {
  grid-row: 2;
  padding: 1.5rem 2rem 2.5rem;
  min-width: 0;
}

.wrap { max-width: var(--wrap-max); margin: 0 auto; }

/* Forms read badly at full width, so they keep their own narrower cap. */

.page-head { margin-bottom: 1.1rem; }
.page-head h1 { font-size: 1.85rem; }
.page-head p { color: var(--slate); margin: .3rem 0 0; }

/* ---------- Panels, stats, tables ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

/* Stacked panels space themselves; inside a grid the gap does that job. */
.wrap > .card + .card,
.wrap > .card + .grid,
.wrap > .grid + .grid,
.wrap > .grid + .card { margin-top: .85rem; }

/* A short full-width panel: text left, one action right. */
.strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.strip__title { margin-bottom: .2rem; }

.card h2 { font-size: 1.1rem; margin-bottom: .75rem; }
.card--narrow { max-width: 46rem; }
.card--danger { border-color: #f2c6c2; }

.card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .9rem;
}
.card__head h2 { margin: 0; }
.card__head > a:not(.btn) { font-size: .9rem; }

/* Panels size to their own content rather than stretching to the tallest. */
.grid { display: grid; gap: .85rem; align-items: start; }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
/* Nine profile fields in three columns, no full-width rows. */
.form-grid--3 .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid--3 .span-all { grid-column: auto; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); align-items: stretch; }
.stat { padding: .9rem 1.1rem; }

/* Tiles that filter the list under them. */
.stat--link { text-decoration: none; color: inherit; transition: border-color .12s ease; }
.stat--link:hover { border-color: var(--orange); color: inherit; }
.stat--on { border-color: var(--orange); background: var(--peach-pale); }
.stat--on .stat__label { color: var(--orange-dark); }
.grid--split { grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }
/* Exactly two, however wide the screen gets: these panels hold addresses
   and small tables, which read badly squeezed into a quarter of a page. */
.grid--pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--account { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.span-all { grid-column: 1 / -1; }

/* Paired inputs inside a panel. Fields marked span-all take the row. */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
}
.form-grid .field--inline { grid-column: 1 / -1; }

/* Every tile the same height, number and label on the same baseline. */
.stat { padding: 1.1rem 1.25rem; display: flex; flex-direction: column; }

.stat .stat__value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  min-height: 2rem;
  display: flex;
  align-items: flex-end;
}
.stat .stat__value--text { font-size: 1.35rem; }

.stat .stat__label {
  margin-top: .45rem;
  font-size: .85rem;
  color: var(--slate);
}

.stat .stat__note { margin: .25rem 0 0; font-size: .8rem; color: var(--slate); }

/* ---------- Small utilities used across pages ---------- */

.link { text-decoration: none; }
.link--strong { font-weight: 600; }
.small { font-size: .85rem; }
.tiny { font-size: .82rem; }
.normal { font-weight: 400; }
.strong { font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.dim { opacity: .7; }
.w-8 { width: 8rem; }
.mt { margin-top: 1rem; }
.mt-s { margin-top: .5rem; }
.mb { margin-bottom: 1rem; }
.mb-s { margin-bottom: .6rem; }
.mb-0 { margin-bottom: 0; }
.danger-text { color: var(--err); }
.h1-sub { font-size: 1rem; font-weight: 500; }

.crumb { margin: 0 0 .3rem; font-size: .85rem; color: var(--slate); }
.sub { color: var(--slate); font-size: .9rem; margin: -.4rem 0 .9rem; }
.actions { display: flex; gap: .6rem; margin-top: .5rem; flex-wrap: wrap; }
.pager { display: flex; gap: .5rem; align-items: center; margin-top: 1.25rem; }

/* "Showing 10 of 23" with the way to the rest. */
.more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: .9rem;
  padding-top: .8rem;
  border-top: 1px solid var(--line);
}
.plain-list { margin: 0 0 1rem; padding-left: 1.2rem; }
.steps { margin: 0; padding-left: 1.2rem; font-size: .9rem; line-height: 1.8; }
.pre { white-space: pre-wrap; margin: .6rem 0 0; font-size: .82rem; }
.code {
  font-size: .78rem;
  background: var(--page);
  padding: .1rem .4rem;
  border-radius: 4px;
}
.empty__text { max-width: 34rem; margin: .4rem auto 1rem; }
.logo--auth { margin-bottom: 2rem; }

.page-head--split {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-head__aside { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

/* Who is working on this, stated at the top of the page rather than
   buried in a list of dates. */
.assignee {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .3rem .9rem .3rem .35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}
.assignee--none { padding-left: .9rem; }
.assignee__label {
  display: block;
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--slate);
  line-height: 1.1;
}
.assignee strong { font-size: .92rem; line-height: 1.25; }
.assignee--none strong { color: var(--slate); font-weight: 500; }

.search { display: flex; gap: .5rem; margin-bottom: 1.25rem; }
.search__input {
  flex: 1;
  padding: .6rem .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
}

.check {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
  margin-bottom: .9rem;
  font-size: .9rem;
}
.check input { margin-top: .2rem; }

.field--auto { flex: 0 0 auto; min-width: 0; }

/* Permission tick-boxes on the Staff pages. */
.perms {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem 1rem .3rem;
  margin: .25rem 0 1.1rem;
}
.perms legend { font-weight: 600; font-size: .85rem; padding: 0 .35rem; }
.perms__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.perms .check { margin-bottom: .5rem; line-height: 1.3; }
.perms .check input { margin-top: .25rem; }
.perms__note { margin: 0 0 .5rem; }

/* Two blocks across a full-width panel: fields left, tick-boxes right. */
.side-by-side {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 0 2rem;
  align-items: start;
}
.side-by-side .perms { margin-top: 0; }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* A soft edge hints that there is more to the right. */
  background:
    linear-gradient(90deg, var(--card) 30%, rgba(255,255,255,0)) left / 2rem 100% no-repeat,
    linear-gradient(270deg, var(--card) 30%, rgba(255,255,255,0)) right / 2rem 100% no-repeat;
  background-attachment: local, local;
}

table { width: 100%; border-collapse: collapse; font-size: .9rem; }

th {
  text-align: left;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--slate);
  font-weight: 600;
  padding: .55rem .6rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td { padding: .8rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--page); }

/* A build that is waiting on whoever is looking at it. The tag alone is
   easy to skim past down a long list; a tinted row with a red edge is
   not. Set on the cells, because a row background loses to the cells. */
tbody tr.row--yours td { background: #fff6f5; }
tbody tr.row--yours:hover td { background: #ffeeec; }
tbody tr.row--yours td:first-child { box-shadow: inset 3px 0 0 var(--err); }

.pill {
  display: inline-block;
  font-size: .85rem;
  font-weight: 600;
  padding: .3rem .75rem;
  line-height: 1.35;
  border-radius: 999px;
  white-space: nowrap;
}

.pill--active    { background: var(--ok-bg); color: var(--ok); }
.pill--suspended { background: var(--err-bg); color: var(--err); }
.pill--admin     { background: var(--lilac-pale); color: var(--purple-mid); }
.pill--client    { background: var(--peach); color: var(--orange-dark); }

/* Build status: open work in lilac/peach, finished in green, stopped in grey. */
.pill--status-queued    { background: var(--lilac-pale); color: var(--purple-mid); }
.pill--status-designing { background: #dfeeff; color: #1d4f9a; }
.pill--status-review    { background: var(--peach); color: var(--orange-dark); }
.pill--status-completed { background: var(--ok-bg); color: var(--ok); }
.pill--status-on_hold   { background: var(--warn-bg); color: var(--warn); }
.pill--status-cancelled { background: #eceff3; color: var(--slate); text-decoration: line-through; }

/* Who owes whom. Small caps so it reads as a label beside the name
   rather than competing with it, and the colour follows the viewer:
   red is always "this one is yours". */
.pill--state {
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: .24rem .55rem;
  vertical-align: .08em;
}
.pill--state-new     { background: var(--lilac-pale); color: var(--purple-mid); }
.pill--state-action  { background: var(--err-bg);     color: var(--err); }
.pill--state-waiting { background: #eceff3;           color: var(--slate); }

/* "10 days left" under a due date. Sits on its own line so it never
   pushes the date itself out of a narrow column. Quiet beyond ten days,
   warmer inside ten, red inside three, and filled once it has gone. */
.due {
  display: block;
  margin-top: .15rem;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.due--far    { color: var(--slate); font-weight: 500; }
.due--soon   { color: var(--warn); }
.due--urgent { color: var(--err); }
.due--late {
  display: inline-block;
  margin-top: .2rem;
  padding: .1rem .45rem;
  border-radius: 999px;
  color: var(--err);
  background: var(--err-bg);
}

.pill--priority-low    { background: #eceff3; color: var(--slate); }
.pill--priority-normal { background: var(--lilac-pale); color: var(--purple-mid); }
.pill--priority-high   { background: var(--peach); color: var(--orange-dark); }
.pill--priority-urgent { background: var(--err-bg); color: var(--err); }

.overdue { color: var(--err); font-weight: 600; }

.muted { color: var(--slate); }
.empty { text-align: center; padding: 1.25rem 1rem; color: var(--slate); }
.empty p { margin: 0 auto .35rem; }
.empty .empty__text { margin: .4rem auto 1rem; }

.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Label/value rows with a rule between them. No column gap, so each
   row's underline runs unbroken across both cells; the label gets
   padding-right instead. */
.definition { display: grid; grid-template-columns: 8rem 1fr; font-size: .9rem; }

.definition dt,
.definition dd {
  padding: .45rem 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
/* Break a long address or URL, but prefer a natural point first. */
.definition dd { overflow-wrap: break-word; word-break: normal; }
.definition dd a { overflow-wrap: anywhere; }

.definition dt { color: var(--slate); padding-right: 1rem; }
.definition dd { margin: 0; font-weight: 500; }

.definition dt:first-of-type,
.definition dd:first-of-type { padding-top: 0; }

.definition dt:last-of-type,
.definition dd:last-of-type { border-bottom: 0; padding-bottom: 0; }

.brief {
  white-space: pre-wrap;
  line-height: 1.6;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem 1rem;
}

/* Toolbar: underlined tabs on the left, filter controls on the right. */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin: -.25rem 0 1rem;
  border-bottom: 1px solid var(--line);
}

.tabs { display: flex; gap: 1.5rem; }
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 0 .65rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--slate);
  font-weight: 600;
  text-decoration: none;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--orange); }
.tabs__count {
  font-size: .75rem;
  font-weight: 600;
  padding: .05rem .45rem;
  border-radius: 999px;
  background: var(--page);
  color: var(--slate);
}
.tabs a[aria-current="page"] .tabs__count { background: var(--peach); color: var(--orange-dark); }

/* Divides "which builds" from "which stage" in the same strip of tabs. */
.tabs__sep {
  flex: 0 0 auto;
  align-self: center;
  width: 1px;
  height: 1.1rem;
  margin: 0 -.35rem;
  background: var(--line);
}

.toolbar__filters { display: flex; gap: .5rem; align-items: center; padding-bottom: .65rem; flex-wrap: wrap; }
.toolbar__filters .search__input { width: 16rem; flex: 0 1 auto; }

.select {
  padding: .5rem .7rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* Who else has this build open. Amber because it is a warning - someone
   may already be answering - and the faces overlap so a few of them stay
   compact beside the heading. */
.viewers {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
  margin-bottom: .8rem;
  padding: .45rem .65rem;
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: .85rem;
  font-weight: 600;
}
.viewers__faces { display: inline-flex; flex: 0 0 auto; }
.viewers__faces .avatar {
  margin-right: -.45rem;
  border: 2px solid var(--warn-bg);
  background: var(--lilac-pale);
  color: var(--purple-mid);
}
.viewers__faces .avatar:last-child { margin-right: 0; }
.viewers__text { min-width: 0; }

/* ---- Internal notes overlay ----------------------------------------
   Driven by :target, so it opens with no JavaScript at all. Our CSP
   forbids inline handlers, and a staff-only panel is the last thing that
   should stop working because a script did not load. Closing points back
   at the button that opened it, so the page does not jump to the top.
   Nothing here hides a note: the whole block is inside an admin branch in
   build.php, so a client is never sent the markup. */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 60;
  padding: 1.5rem;
  align-items: center;
  justify-content: center;
}
.modal:target { display: flex; }

.modal__scrim { position: absolute; inset: 0; background: rgba(13, 21, 38, .55); }

.modal__card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 46rem;
  max-height: 86vh;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem .9rem;
  border-bottom: 1px solid var(--line);
}
.modal__head h2 { margin: 0; }
.modal__sub { margin: .4rem 0 0; font-size: .85rem; color: var(--slate); }
.modal__close {
  flex: 0 0 auto;
  font-size: 1.6rem;
  line-height: 1;
  text-decoration: none;
  color: var(--slate);
  padding: 0 .35rem;
  border-radius: var(--radius);
}
.modal__close:hover { background: var(--page); color: var(--ink); }

.modal__body { flex: 1; overflow-y: auto; padding: .3rem 1.25rem; }
.modal__foot {
  padding: .9rem 1.25rem 1.05rem;
  border-top: 1px solid var(--line);
  background: var(--page);
  border-radius: 0 0 var(--radius) var(--radius);
}
.modal__foot .field { margin-bottom: .6rem; }

.note { display: flex; gap: .8rem; padding: .9rem 0; border-top: 1px solid var(--line); }
.note:first-child { border-top: 0; }
.note__body { min-width: 0; flex: 1; }
.note__head { display: flex; align-items: center; gap: .5rem; margin-bottom: .25rem; }
.note__head strong { font-size: .9rem; color: var(--ink); }
.note__when { margin-left: auto; font-size: .78rem; color: var(--slate); white-space: nowrap; }
.note__text { font-size: .92rem; color: var(--ink); line-height: 1.6; }
.note__remove { display: inline; }
.note__remove button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: .78rem;
  color: var(--slate);
  cursor: pointer;
}
.note__remove button:hover { color: var(--err); }

/* The way in, marked as internal so it is never mistaken for the
   client-facing conversation. */
.btn--note { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.btn--note:hover { background: #f8e6c4; color: var(--warn); }
.btn__count {
  display: inline-block;
  margin-left: .35rem;
  padding: 0 .4rem;
  border-radius: 999px;
  background: rgba(138, 83, 0, .16);
  font-size: .78rem;
}
.pill--staff-only { background: var(--warn-bg); color: var(--warn); margin-right: .4rem; }

.select--sm { padding: .32rem .5rem; font-size: .85rem; }

/* The schedule's status picker keeps the colour the old pill had, so a
   long schedule is still scannable at a glance. */
.ms-status { display: flex; gap: .4rem; align-items: center; }
.select--ms-planned     { background: var(--lilac-pale); color: var(--purple-mid); }
.select--ms-in_progress { background: #dfeeff;           color: #1d4f9a; }
.select--ms-done        { background: var(--ok-bg);      color: var(--ok); }

.empty__title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--ink); margin: 0 0 .3rem; }
.empty .btn { margin-top: .6rem; }

.filters { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.filters a {
  text-decoration: none;
  font-size: .85rem;
  padding: .35rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--slate);
  background: #fff;
}
.filters a[aria-current="true"] { background: var(--purple); border-color: var(--purple); color: #fff; }

/* ---------- Build request form and files ---------- */

.build-form { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 0 2rem; align-items: start; }
.build-form .section { grid-column: 1 / -1; }

/* Rows of sections across the width: three text blocks, then two uploads. */
.build-form__row {
  grid-column: 1 / -1;
  display: grid;
  gap: 0 1.5rem;
  border-top: 1px solid var(--line);
  margin-top: .5rem;
}
.build-form__row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.build-form__row--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.build-form__row .section { grid-column: auto; border-top: 0; margin-top: 0; }
.build-form__row .field textarea { min-height: 6.5rem; }
.build-form > div > .field textarea { min-height: 6.5rem; }

.section { padding-top: 1rem; margin-top: .5rem; border-top: 1px solid var(--line); }
.section h3 { font-size: 1rem; margin-bottom: .2rem; }
.section .sub { margin: 0 0 .8rem; }

.field input[type="file"] { padding: .4rem; background: var(--page); }

/* Thumbnails and file rows on the build page. */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .8rem; }
.file {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  font-size: .8rem;
}
.file__thumb {
  display: block;
  aspect-ratio: 4 / 3;
  width: 100%;
  object-fit: cover;
  background: var(--page);
}
.file__icon {
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page);
  color: var(--slate);
  font-weight: 700;
  font-size: .85rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.file__meta { padding: .5rem .6rem; }
.file__name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file__actions { display: flex; gap: .5rem; margin-top: .3rem; }
.file__actions form { display: inline; }
.file__actions button { background: none; border: 0; padding: 0; font: inherit; font-size: .8rem; color: var(--err); cursor: pointer; }

/* Colour swatches parsed from the colour notes. */
.swatches { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.swatch {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .15rem .6rem .15rem .2rem;
}
.swatch svg { display: block; }
.files__kind { font-size: .85rem; font-weight: 600; margin: .4rem 0 .5rem; }

.plain-list--tight { margin: 0; padding-left: 1.2rem; line-height: 1.7; }

/* Error log rows. */
.log td { padding: .45rem .6rem; font-size: .8rem; }
.log code { white-space: pre-wrap; word-break: break-word; font-size: .78rem; }
.log--error td { background: var(--err-bg); }
.log--warn td { background: #fff4d6; }

/* Build page: conversation and content left, reference panels right. */
.build-layout {
  display: grid;
  /* The reference column keeps a sensible width instead of growing with
     the page; the conversation takes whatever is left. */
  grid-template-columns: minmax(0, 1fr) minmax(17rem, 24rem);
  gap: .85rem;
  align-items: start;
}
.build-layout__main > .card + .card,
.build-layout__side > .card + .card { margin-top: .85rem; }

/* ---------- Build conversation ---------- */

.badge-new {
  display: inline-block;
  vertical-align: middle;
  font-size: .7rem;
  font-weight: 700;
  padding: .08rem .45rem;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  white-space: nowrap;
}

/* Reads as a ticket thread, not a chat: no tinted bubbles per speaker.
   Messages are separated by a rule, the words carry the weight, and the
   side is signalled only by the avatar colour and the small tag. */
.thread { margin: .4rem 0 0; }

.msg {
  display: flex;
  gap: .8rem;
  align-items: flex-start;
  padding: .95rem 0;
  border-top: 1px solid var(--line);
}
.msg:first-child { border-top: 0; padding-top: .15rem; }

/* Our turns sit on a faint band, so a long thread reads as a back and
   forth at a glance instead of one wall of text. Neutral grey on purpose:
   a tint borrowed from the brand made the thread look decorative rather
   than like a record of who said what. The band insets are smaller than
   the card's own padding at every width, so it never touches the edge. */
.msg--staff {
  background: #f4f5f7;
  border-radius: var(--radius);
  padding: .95rem .8rem;
  margin: 0 -.8rem;
}
.msg--staff:first-child { padding-top: .8rem; }
.msg--staff + .msg--staff { border-top-color: #e6e8ec; }

.avatar--sm { width: 2rem; height: 2rem; font-size: .72rem; }
.msg--client .avatar { background: var(--lilac); color: var(--purple); }

.msg__body { min-width: 0; flex: 1; }

/* Quieter than the message itself, so the words lead. */
.msg__head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .3rem;
  font-size: .82rem;
  color: var(--slate);
}
.msg__head strong { font-size: .9rem; color: var(--ink); }
.msg__when { margin-left: auto; font-size: .78rem; white-space: nowrap; }

.msg__tag {
  font-size: .63rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .1rem .4rem;
  border-radius: 4px;
  background: var(--lilac-pale);
  color: var(--purple-mid);
}
.msg__tag--staff { background: var(--peach); color: var(--orange-dark); }

.msg__you {
  font-size: .7rem;
  color: var(--slate);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 .4rem;
}

.msg__remove { display: inline; }
.msg__remove button {
  background: none;
  border: 0;
  padding: 0 0 0 .5rem;
  font: inherit;
  font-size: .75rem;
  color: var(--slate);
  cursor: pointer;
}
.msg__remove button:hover { color: var(--err); }

.msg__via {
  display: block;
  font-size: .78rem;
  font-style: italic;
  color: var(--slate);
  margin: -.15rem 0 .35rem;
}

/* No panel and no tint: the size and colour do the work. */
.msg__text {
  color: var(--ink);
  font-size: .95rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

/* Files sent with a message, under its text. */
.msg__files { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .55rem; }

.msg__file {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  max-width: 100%;
  padding: .3rem .6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--page);
  font-size: .8rem;
  text-decoration: none;
  color: var(--ink);
}
.msg__file:hover { border-color: var(--orange); color: var(--ink); }
.msg__file-kind {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--slate);
}
.msg__file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14rem; }

.msg__file--image { padding: 0; overflow: hidden; border-radius: var(--radius); }
.msg__file--image img { display: block; height: 5.5rem; width: auto; max-width: 11rem; object-fit: cover; }

/* Status changes and the opening line: a quiet rule across the thread,
   clearly not someone speaking. */
.msg--system {
  gap: .75rem;
  align-items: center;
  font-size: .8rem;
  color: var(--slate);
}
.msg--system::before,
.msg--system::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.msg--system span { flex: 0 1 auto; text-align: center; }
.msg--system time { white-space: nowrap; font-size: .75rem; opacity: .8; }

/* Type, file picker and the button on one line; the picker takes the slack. */
.upload-row {
  display: grid;
  grid-template-columns: minmax(9rem, auto) minmax(0, 1fr) auto;
  gap: .8rem;
  align-items: end;
}
.upload-row .field { margin-bottom: 0; }
.upload-row .btn { margin-bottom: .05rem; }

.compose { border-bottom: 1px solid var(--line); padding-bottom: 1rem; margin-bottom: .2rem; }
.compose textarea { min-height: 4.5rem; }
.compose .actions { margin-top: 0; align-items: center; justify-content: space-between; }

/* The client's decision when a build is waiting on them. Tinted so it
   reads as something to act on rather than more detail. */
.review { border-color: #ffd9bd; background: var(--peach-pale); }
.review .sub { color: var(--orange-dark); }
.review__actions { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.review__changes { flex: 1; min-width: 18rem; }
.review__changes summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  color: var(--orange-dark);
  padding: .55rem 0;
}
.review__changes summary:hover { color: var(--orange-btn-dark); }
.review__changes[open] summary { margin-bottom: .4rem; }
.review__changes textarea { background: #fff; }

/* A stored secret, rendered read-only and masked until revealed. */
.secret { display: block; margin: 0; }
.secret__value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--page);
}
.staging-edit summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .85rem;
  color: var(--orange-dark);
  padding: .4rem 0;
}
.staging-edit summary:hover { color: var(--orange-btn-dark); }
.staging-edit[open] summary { margin-bottom: .4rem; }

/* Show / hide control inside a password box. */
.pw { position: relative; display: block; }
.pw input { padding-right: 4rem; }
.pw__toggle {
  position: absolute;
  top: 50%;
  right: .35rem;
  transform: translateY(-50%);
  background: none;
  border: 0;
  padding: .25rem .5rem;
  border-radius: 4px;
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  color: var(--slate);
  cursor: pointer;
}
.pw__toggle:hover { color: var(--ink); background: var(--page); }

.pw-match { font-size: .8rem; margin: .3rem 0 0; }
.pw-match--yes { color: var(--ok); }
.pw-match--no { color: var(--err); }

/* A permission, in a word or two, for a table cell. */
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  padding: .1rem .45rem;
  border-radius: 4px;
  background: var(--lilac-pale);
  color: var(--purple-mid);
  white-space: nowrap;
}
.chip--all { background: var(--peach); color: var(--orange-dark); }

/* Grouped by the area a permission acts on, so a row of them scans. */
.chip-group { display: inline-flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.chip-group__name {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--slate);
  margin-right: .1rem;
}
.chip-group--clients .chip  { background: var(--lilac-pale); color: var(--purple-mid); }
.chip-group--builds .chip   { background: var(--peach); color: var(--orange-dark); }
.chip-group--activity .chip { background: #dfeeff; color: #1d4f9a; }

/* Who is about. A dot rather than a pill, so a table of them is calm. */
.presence { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
.presence__dot {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--line);
}
.presence--online { color: var(--ok); font-weight: 600; }
.presence--online .presence__dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-bg);
}
.presence--recent { color: var(--orange-dark); }
.presence--recent .presence__dot { background: var(--orange); }
.presence--away, .presence--never { color: var(--slate); }
.presence--never .presence__dot { background: transparent; border: 1px solid var(--line); }

/* A build's reference, quoted in emails and on the phone. */
.ref {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--slate);
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .1rem .4rem;
  white-space: nowrap;
}
h1 .ref { font-size: .95rem; vertical-align: middle; margin-left: .3rem; }

/* ---------- Timetable ---------- */

/* A month grid. The 1px gap on a --line background draws the rules, so
   no cell needs its own border. */
.cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.cal__dow {
  background: var(--page);
  padding: .4rem .5rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--slate);
  text-align: center;
}

.cal__day { background: #fff; min-height: 6.5rem; padding: .35rem .4rem; }
.cal__day--out { background: #fbfafc; }
.cal__day--out .cal__num { opacity: .45; }
.cal__day--today { box-shadow: inset 0 0 0 2px var(--orange); }

.cal__num { font-size: .78rem; font-weight: 600; color: var(--slate); margin-bottom: .15rem; }

.cal__item {
  display: block;
  margin-top: .2rem;
  padding: .2rem .35rem;
  border-left: 3px solid var(--lilac);
  border-radius: 0 4px 4px 0;
  background: var(--lilac-pale);
  color: var(--purple-mid);
  font-size: .74rem;
  line-height: 1.3;
  text-decoration: none;
  overflow: hidden;
}
.cal__item strong { display: block; font-weight: 600; }
.cal__item-site { display: block; opacity: .75; font-size: .7rem; }
.cal__item:hover { filter: brightness(.97); }

.cal__item--build    { background: var(--peach); color: var(--orange-dark); border-left-color: var(--orange); }
.cal__item--overdue  { background: var(--err-bg); color: var(--err); border-left-color: var(--err); }
.cal__item--done     { background: var(--ok-bg); color: var(--ok); border-left-color: var(--ok); }
.cal__item--done strong { text-decoration: line-through; }

/* The lists above and below the calendar. */
.sched-list { display: flex; flex-direction: column; }
.sched-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: .55rem 0;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
}
.sched-row:first-child { border-top: 0; }
.sched-row:hover { background: var(--page); }
.sched-row__date { flex: 0 0 8rem; font-weight: 600; font-size: .88rem; }
.sched-row__date .tiny { display: block; font-weight: 400; }
.sched-row__what { flex: 1; min-width: 0; }
.sched-row__what .tiny { display: block; }
.sched-row__who { flex: 0 0 auto; }
.sched-row--overdue .sched-row__date { color: var(--err); }

/* Milestone status on the build page. */
.pill--ms-planned     { background: var(--lilac-pale); color: var(--purple-mid); }
.pill--ms-in_progress { background: #dfeeff; color: #1d4f9a; }
.pill--ms-done        { background: var(--ok-bg); color: var(--ok); }
.pill--button { border: 0; cursor: pointer; font-family: inherit; }
.pill--button:hover { filter: brightness(.95); }

/* ---------- Responsive ---------- */

@media (max-width: 60rem) {
  .auth { grid-template-columns: 1fr; }
  /* The marketing panel is decorative; drop it before it squeezes the form. */
  .auth__aside { display: none; }

  /* Sidebar becomes a top bar; groups flow into one wrapping row. */
  .shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .sidebar {
    grid-row: 2;
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
    padding: .75rem 1rem;
  }
  .sidebar__brand { padding: 0 .75rem 0 0; }
  .sidebar__group { display: none; }
  .sidebar a.nav { padding: .4rem .65rem; border-left: 0; font-size: .9rem; }
  .sidebar a.nav[aria-current="page"] { border-left: 0; }
  .sidebar__foot { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; gap: .75rem; align-items: baseline; }
  .sidebar__foot a { margin: 0; }
  .sidebar__foot .role { display: none; }
  .main { grid-row: 3; padding: 1.5rem 1.25rem 2.5rem; }
}

@media (max-width: 60rem) {
  .grid--pair { grid-template-columns: 1fr; }
  .side-by-side { grid-template-columns: 1fr; }
  .grid--3 { grid-template-columns: 1fr; }
  .build-layout { grid-template-columns: 1fr; }
  .upload-row { grid-template-columns: 1fr; align-items: stretch; }
  .span-2 { grid-column: auto; }
  .form-grid--3 .form-grid { grid-template-columns: 1fr; }
  .build-form { grid-template-columns: 1fr; }
  .build-form__row--3, .build-form__row--2 { grid-template-columns: 1fr; }
}

@media (max-width: 52rem) {
  /* A seven-column month does not fit a phone; the lists carry it. */
  .cal { display: none; }
  .sched-row { flex-wrap: wrap; gap: .2rem .8rem; }
  .sched-row__date { flex: 0 0 100%; }
}

@media (max-width: 48rem) {
  /* Tabs and filters stop sharing a line; the search takes the width. */
  .toolbar { flex-direction: column; align-items: stretch; gap: .25rem; }
  .toolbar__filters { padding-bottom: .8rem; }
  .toolbar__filters .search__input { width: 100%; flex: 1 1 100%; }
  .toolbar__filters .select { flex: 1 1 auto; }

  /* Three tabs with counts do not fit a phone: let them scroll sideways
     rather than wrap into a ragged block. */
  .tabs {
    gap: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { white-space: nowrap; }

  .pager { flex-wrap: wrap; }

  /* The time drops under the name instead of being pushed off the edge. */
  .msg__when { margin-left: 0; width: 100%; }
  .msg__file-name { max-width: 9rem; }

  .review__changes { min-width: 0; }
  .search { flex-wrap: wrap; }
  .search__input { flex: 1 1 100%; }
}

@media (max-width: 40rem) {
  .modal { padding: .75rem; }
  .modal__card { max-height: 92vh; }
  .modal__head, .modal__body, .modal__foot { padding-left: .9rem; padding-right: .9rem; }

  .grid--account { grid-template-columns: 1fr; }
  .perms__grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  /* Stacked: the label sits above its value, so only the value carries
     the rule that ends the row. */
  .definition { grid-template-columns: 1fr; }
  .definition dt { padding: .45rem 0 0; border-bottom: 0; }
  .definition dd { padding-top: .1rem; }
  .page-head h1 { font-size: 1.5rem; }
}

@media (max-width: 30rem) {
  .main { padding: 1.1rem .85rem 2rem; }
  .card { padding: .9rem 1rem; }
  .grid--stats { grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); }
  .stat .stat__value { font-size: 1.7rem; }
  .field--inline > * { min-width: 0; flex: 1 1 100%; }
  .actions { flex-direction: column; align-items: stretch; }
  .actions .btn { width: 100%; }
  .msg { gap: .55rem; }
  .avatar--lg { width: 3.5rem; height: 3.5rem; font-size: 1.1rem; }
  .photo-form { gap: .75rem; }
  .msg__file--image img { height: 4.5rem; max-width: 8rem; }
}

@media (pointer: coarse) {
  .btn--sm { padding: .5rem .85rem; }
  .sidebar a.nav { padding: .7rem .75rem; }
  .tabs a { padding: .7rem 0 .8rem; }
  .filters a { padding: .5rem .85rem; }
  .msg__remove button { padding: .35rem .5rem; }
  .pw__toggle { padding: .45rem .6rem; }
}
