@layer tokens, base, page, island;

/* The only rule that names a font. To swap the font, replace the file in
   static/fonts/ and this src line. Every other rule uses --font. */
@font-face {
  font-family: "Hutch Sans";
  src: url("fonts/Archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* A copy of design/tokens.css. Change that file first, then this block. */
@layer tokens {
  :root {
    /* Hutch accent (core brand) */
    --accent: #C26932;          /* non-text marks only: today, progress, active nav tile, focus ring, logo */
    --accent-strong: #A85A29;   /* fills behind white text (5.1:1) */
    --accent-ink: #8C4720;      /* accent-colored text and links on white */
    --accent-tint: #F8EBE2;     /* active nav fill, registration-open surfaces, unread */
    --accent-tint-2: #EDD5C5;   /* progress track on accent-tint */

    /* Neutrals */
    --ink: #1C1C1C;
    --ink-1: #2E2E2E;           /* headings */
    --ink-2: #3A3A3A;           /* body in panels */
    --ink-3: #4A4A4A;           /* labels, secondary buttons */
    --ink-4: #5E5E5E;           /* secondary text */
    --meta: #707070;            /* lightest allowed text (4.9:1 on white) */
    --disabled: #8A8A8A;        /* struck-through / cancelled text */
    --line: #D4D4D4;
    --fill-closed: #E6E6E6;     /* closure day, cancelled chip */
    --fill-track: #E3E3E3;      /* capacity bar track */
    --fill-2: #EAEAEA;          /* neutral tag */
    --fill-1: #F3F3F3;          /* app ground, quiet buttons, segmented track (#E9E9E9 on ground) */
    --fill-0: #F6F6F6;          /* rows, day columns, calendar days */
    --fill-faint: #FAFAFA;      /* ended and ghost cards */
    --line-card: #E2E2E2;       /* card border on Programs (issue #44) */
    --paper: #FFFFFF;

    /* At risk: a class short of its minimum, a deadline coming up. Peach means
       open, and amber means at risk; neither stands in for the other. */
    --risk-mark: #B8740F;       /* filled dots */
    --risk-ink: #7A4A00;        /* 6.7:1 on --risk-tint */
    --risk-tint: #FFF0D4;

    /* Nav tile grays (inactive), one per destination */
    --tile-home: #5F6367;
    --tile-programs: #736F6B;
    --tile-calendar: #868A8D;
    --tile-families: #A39E98;

    /* Type */
    --font: "Hutch Sans", system-ui, sans-serif;
    --text-meta: 0.8125rem;     /* 13 */
    --text-body: 0.9375rem;     /* 15 */
    --text-section: 1.125rem;   /* 18 */
    --text-title: 1.625rem;     /* 26 */
    --text-question: 2rem;      /* 32 */
    --text-display: 2rem;       /* 32 / 300 weight, calendar month */
    --tracking-overline: 0.06em;

    /* Space (4px base) */
    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
    --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-11: 44px; --space-16: 64px;

    /* Shape */
    --radius: 8px;              /* default: cards, buttons, tiles, rows */
    --radius-sm: 6px;           /* tags, session chips, segmented options */
    --radius-card: 10px;        /* Programs cards and menus (issue #44) */
    --radius-lg: 12px;          /* floating sheets, overlapping info card */
    --radius-sheet: 16px;       /* the top of a phone's bottom sheet */
    --radius-pill: 999px;       /* filter chips, avatars */

    /* Elevation: shapes over lines. Use sparingly. */
    --shadow-card: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
    --shadow-chip: 0 1px 2px rgba(0,0,0,.06);
    --shadow-seg: 0 1px 3px rgba(0,0,0,.10);    /* selected segmented option */
    --shadow-sheet: 0 4px 20px rgba(0,0,0,.08);
    --shadow-flat: 0 1px 2px rgba(0,0,0,.04);   /* a bordered card */
    --shadow-menu: 0 10px 28px rgba(0,0,0,.14);
    --shadow-float: 0 8px 24px rgba(0,0,0,.18); /* select bar, toast */

    /* Layout */
    --sidebar: 232px; --sidebar-collapsed: 72px; --topbar: 64px; --notes-panel: 340px;

    /* Client brand (overridden per tenant, see README › Client branding) */
    --brand-primary: var(--ink-4);
    --brand-primary-fill: var(--ink-4);   /* primary deepened until white text passes 4.5:1 */
    --brand-on-primary: #FFFFFF;
    --brand-primary-ink: var(--ink-1);    /* primary darkened for headings on white */
    --brand-primary-tint: #EEEEEE;        /* primary mixed 86–93% toward white */
    --brand-secondary: var(--disabled);
    --brand-secondary-tint: var(--fill-0);/* secondary mixed 82–88% toward white */
    --brand-ground: var(--fill-1);        /* background, lightened if luminance < .82 */
  }
}

@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  /* An element that sets its own display would otherwise ignore hidden. */
  [hidden] {
    display: none !important;
  }

  /* Needs you collapses on a phone alone. An important rule in a later layer
     loses to the one above, so this one sits in the same layer. */
  @media (min-width: 721px) {
    #needs-list[hidden] {
      display: flex !important;
    }
  }

  body {
    margin: 0;
    background: var(--brand-ground);
    color: var(--ink);
    font-family: var(--font);
    font-size: var(--text-body);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }

  h1,
  h2,
  h3 {
    margin: 0;
    color: var(--brand-primary-ink);
    font-weight: 600;
    line-height: 1.25;
  }

  h1 {
    font-size: var(--text-title);
    letter-spacing: -0.02em;
  }

  h2 {
    font-size: var(--text-section);
    letter-spacing: -0.01em;
  }

  h3 {
    font-size: var(--text-body);
  }

  p {
    margin: 0;
  }

  b,
  strong {
    font-weight: 600;
  }

  a {
    color: var(--accent-ink);
    font-weight: 600;
    text-decoration: none;
  }

  a:hover {
    color: #6E3818;
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }

  button,
  input,
  select,
  textarea {
    font: inherit;
    color: inherit;
  }

  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

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

@layer page {
  /* Auth pages: one card on the ground. */
  .h-auth {
    width: min(100%, 26rem);
    margin-inline: auto;
    padding: var(--space-16) var(--space-4);
  }

  /* Brand mark */
  .h-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
  }

  .h-brand-tile {
    display: grid;
    flex: none;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--paper);
    font-size: 1rem;
    font-weight: 800;
  }

  .h-brand-name {
    color: var(--ink-1);
    font-size: 1.1875rem;
    font-weight: 800;
    letter-spacing: -0.02em;
  }

  /* Icons take the text color, and their size from where they sit. */
  .h-icon {
    flex: none;
    width: 18px;
    height: 18px;
  }

  /* App shell: the sidebar spans both rows, and the top bar sits over main. */
  .h-shell {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: var(--topbar) 1fr;
    min-height: 100vh;
  }

  .h-main {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-width: 0;
    padding: var(--space-6) var(--space-8);
  }

  /* Sidebar */
  .h-sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    grid-row: 1 / -1;
    gap: var(--space-1);
    width: var(--sidebar);
    height: 100vh;
    padding: var(--space-4) var(--space-3);
    background: var(--paper);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.04);
    transition: width 0.2s ease;
  }

  .h-shell--collapsed .h-sidebar {
    width: var(--sidebar-collapsed);
  }

  .h-sidebar .h-brand {
    margin-bottom: var(--space-4);
    padding: 0 9px;
    overflow: hidden;
  }

  /* Each row keeps its tile in place and clips its label as the sidebar
     narrows, and the label fades out. The label stays in the accessibility
     tree, so a collapsed row keeps its name. */
  .h-sidebar :is(.h-brand-name, .h-sidebar-label) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 0.2s ease;
  }

  .h-shell--collapsed .h-sidebar :is(.h-brand-name, .h-sidebar-label) {
    opacity: 0;
  }

  .h-nav {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-1);
  }

  .h-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: 44px;
    padding: 0 var(--space-2);
    overflow: hidden;
    border-radius: var(--radius);
    color: var(--ink-3);
    font-size: var(--text-body);
    font-weight: 600;
    cursor: pointer;
  }

  .h-nav-item:hover {
    background: var(--fill-0);
    text-decoration: none;
  }

  .h-nav-item[aria-current="page"] {
    background: var(--accent-tint);
    color: var(--accent-ink);
  }

  /* Plain icons in the row's own color, each in a 24px box (issue #44, § 5). */
  .h-nav-item .h-icon {
    margin-inline: 3px;
  }

  .h-shell--collapsed .h-nav-item {
    padding-inline: var(--space-3);
  }

  .h-collapse {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: 44px;
    padding: 0 14px;
    overflow: hidden;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--meta);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
  }

  .h-collapse .h-icon {
    width: 20px;
    height: 20px;
  }

  /* Top bar */
  .h-topbar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 0 var(--space-8);
    border-bottom: 1px solid var(--line-card);
    background: var(--paper);
  }

  .h-topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .h-location {
    position: relative;
  }

  .h-location-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: 40px;
    padding: 0 var(--space-3);
    border-radius: var(--radius);
    background: var(--fill-1);
    color: var(--ink-1);
    font-size: 0.875rem;
    font-weight: 600;
    list-style: none;
    cursor: pointer;
  }

  .h-location-toggle .h-icon {
    width: 16px;
    height: 16px;
  }

  /* The signed-in person's circle, set a little apart from the actions. */
  .h-profile {
    position: relative;
    margin-left: var(--space-2);
  }

  .h-profile-toggle {
    display: block;
    border-radius: var(--radius-pill);
    list-style: none;
    cursor: pointer;
    transition: box-shadow 0.2s ease;
  }

  /* A details toggle draws no marker, and fills while hovered or open. */
  summary::-webkit-details-marker {
    display: none;
  }

  .h-collapse:hover {
    background: var(--fill-1);
  }

  .h-location-toggle:hover,
  .h-location[open] > .h-location-toggle {
    background: var(--fill-2);
  }

  .h-profile-toggle:hover,
  .h-profile[open] > .h-profile-toggle {
    box-shadow: 0 0 0 4px var(--fill-1);
  }

  /* Menus: a sheet of options beside their toggle. */
  .h-menu {
    position: absolute;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 100%;
    margin: 0;
    padding: var(--space-1);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: var(--shadow-sheet);
    list-style: none;
  }

  .h-location > .h-menu {
    top: calc(100% + var(--space-1));
    left: 0;
    min-width: 220px;
  }

  .h-profile > .h-menu {
    top: calc(100% + var(--space-2));
    right: 0;
    width: 264px;
  }

  /* The profile menu's head: who is signed in, on a fill instead of a rule. */
  .h-profile-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-1);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--fill-0);
  }

  .h-profile-card .h-avatar {
    background: var(--paper);
    box-shadow: var(--shadow-chip);
  }

  .h-profile-who {
    display: grid;
    min-width: 0;
  }

  .h-profile-name,
  .h-profile-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .h-profile-name {
    color: var(--ink-1);
    font-size: var(--text-body);
    font-weight: 600;
  }

  .h-profile-email {
    color: var(--meta);
    font-size: var(--text-meta);
  }

  .h-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    min-height: 40px;
    padding: 0 var(--space-3);
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-2);
    font-size: 0.875rem;
    font-weight: 500;
    text-align: start;
    white-space: nowrap;
    cursor: pointer;
  }

  .h-menu-item:hover {
    background: var(--fill-1);
    text-decoration: none;
  }

  .h-menu-item[aria-current="true"] {
    background: var(--accent-tint);
    color: var(--accent-ink);
  }

  /* Buttons */
  .h-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 40px;
    padding: 0 var(--space-4);
    border: 0;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
  }

  .h-button:hover {
    text-decoration: none;
  }

  .h-button--primary {
    background: var(--accent-strong);
    color: var(--paper);
    box-shadow: 0 2px 6px color-mix(in srgb, var(--accent-strong) 25%, transparent);
  }

  .h-button--primary:hover {
    background: var(--accent-ink);
  }

  .h-button--quiet {
    background: var(--fill-1);
    color: var(--ink-1);
  }

  .h-button--quiet:hover {
    background: var(--fill-2);
  }

  .h-button--raised {
    background: var(--paper);
    color: var(--ink-1);
    box-shadow: var(--shadow-chip);
  }

  .h-button--ghost {
    background: transparent;
    color: var(--ink-3);
  }

  .h-button--ghost:hover {
    background: var(--fill-1);
  }

  .h-button--strong {
    background: var(--ink-1);
    color: var(--paper);
  }

  .h-button--strong:hover {
    background: var(--ink-2);
  }

  .h-button:disabled {
    background: var(--fill-2);
    color: var(--disabled);
    box-shadow: none;
    cursor: not-allowed;
  }

  /* Card and rows */
  .h-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-5);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: var(--shadow-card);
  }

  /* The Programs page's cards, which a Needs you item scrolls clear of the top bar. */
  .h-card--bordered {
    border: 1px solid var(--line-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-flat);
    scroll-margin-top: calc(var(--topbar) + var(--space-4));
  }

  .h-card--ended,
  .h-card--ghost {
    background: var(--fill-faint);
    box-shadow: none;
  }

  .h-card--ended :is(h2, b) {
    color: var(--ink-4);
  }

  .h-card--ghost {
    border: 1px dashed var(--line);
    opacity: 0.6;
    pointer-events: none;
    user-select: none;
  }

  .h-rows {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .h-rows > .h-button {
    align-self: flex-start;
  }

  .h-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) 14px;
    border-radius: var(--radius);
    background: var(--brand-secondary-tint);
  }

  /* A row that is itself a link or a button. */
  a.h-row,
  button.h-row {
    color: inherit;
    font-weight: 400;
    cursor: pointer;
  }

  a.h-row:hover,
  button.h-row:hover {
    background: var(--fill-1);
    text-decoration: none;
  }

  button.h-row {
    width: 100%;
    border: 0;
    text-align: start;
  }

  .h-row > b {
    flex: 1;
  }

  /* Tags */
  .h-tag {
    display: inline-block;
    max-width: 100%;
    padding: 3px 7px;
    overflow: hidden;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--fill-2);
    color: var(--ink-3);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
    text-overflow: ellipsis;
    vertical-align: middle;
    white-space: nowrap;
  }

  .h-tag--attention {
    background: var(--accent-tint);
    color: var(--accent-ink);
  }

  .h-tag--risk {
    background: var(--risk-tint);
    color: var(--risk-ink);
  }

  .h-tag--outline {
    background: transparent;
    box-shadow: inset 0 0 0 1.5px var(--disabled);
  }

  .h-tag--raised {
    background: var(--paper);
    box-shadow: var(--shadow-chip);
  }

  .h-tag--confirmed {
    background: var(--ink-1);
    color: var(--paper);
  }

  .h-tag--cancelled {
    border-color: var(--line);
    background: transparent;
    color: var(--ink-4);
    text-decoration: line-through;
  }

  /* Capacity */
  .h-capacity {
    display: flex;
    align-items: center;
    gap: var(--space-4);
  }

  .h-capacity-meter {
    display: grid;
    flex: 1;
    gap: 6px;
    min-inline-size: 150px;
    color: var(--ink-3);
    font-size: var(--text-meta);
  }

  .h-capacity-bar {
    position: relative;
    display: block;
    height: 6px;
    border-radius: 3px;
    background: var(--fill-track);
  }

  .h-capacity-bar::after {
    content: "";
    display: block;
    width: var(--h-filled, 0%);
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
  }

  .h-capacity-mark {
    position: absolute;
    top: -4px;
    left: calc(var(--h-minimum) - 1px);
    width: 2px;
    height: 14px;
    border-radius: 1px;
    background: var(--ink-1);
  }

  .h-capacity-key,
  .h-saved {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .h-capacity-key .h-capacity-bar {
    flex: 0 0 28px;
  }

  /* Segmented control */
  .h-segmented {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: var(--radius);
    background: var(--fill-2);
  }

  .h-card .h-segmented,
  .h-drawer .h-segmented {
    background: var(--fill-1);
  }

  .h-segment {
    display: inline-flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-3);
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
  }

  .h-segment--open {
    background: var(--accent-tint);
    color: var(--accent-ink);
  }

  .h-segment:is([aria-pressed="true"], [aria-selected="true"]) {
    background: var(--paper);
    color: var(--ink-1);
    box-shadow: var(--shadow-seg);
  }

  .h-badge {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--paper);
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
  }

  /* Filter chips */
  .h-chip {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--paper);
    box-shadow: var(--shadow-chip);
    color: var(--ink-3);
    font-size: var(--text-meta);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
  }

  .h-chip:hover {
    text-decoration: none;
  }

  .h-chip:is([aria-pressed="true"], [aria-current]:not([aria-current="false"])) {
    background: var(--accent-tint);
    box-shadow: none;
    color: var(--accent-ink);
  }

  /* Avatar and monogram */
  .h-avatar,
  .h-monogram {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 40px;
    height: 40px;
  }

  .h-avatar {
    border-radius: var(--radius-pill);
    background: var(--fill-2);
    color: var(--ink-3);
    font-size: 0.75rem;
    font-weight: 600;
  }

  .h-avatars {
    display: flex;
  }

  .h-avatars .h-avatar {
    width: 28px;
    height: 28px;
    box-shadow: 0 0 0 2px var(--paper);
    font-size: 0.625rem;
  }

  .h-avatars .h-avatar + .h-avatar {
    margin-left: -4px;
  }

  .h-monogram {
    border-radius: var(--radius);
    color: var(--paper);
    font-size: 0.875rem;
    font-weight: 800;
    letter-spacing: -0.02em;
  }

  .h-monogram--1 {
    background: var(--tile-home);
  }

  .h-monogram--2 {
    background: var(--tile-programs);
  }

  .h-monogram--3 {
    background: var(--tile-calendar);
  }

  .h-monogram--4 {
    background: var(--tile-families);
  }

  /* Fields, and any other column of things 16px apart */
  .h-form,
  .h-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }

  .h-field {
    display: grid;
    gap: 6px;
  }

  .h-field-label {
    color: var(--ink-2);
    font-size: var(--text-meta);
    font-weight: 600;
  }

  .h-field > :is(input, select, textarea) {
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
    font-size: var(--text-body);
  }

  .h-field > textarea {
    padding-block: 10px;
  }

  .h-field > :is(input, textarea)::placeholder {
    color: var(--meta);
  }

  /* Loading: the bar shows at once, the skeleton after 300ms. */
  :where(:has(> .h-loading)) {
    position: relative;
  }

  .h-loading {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    border-radius: inherit;
    pointer-events: none;
  }

  :is(.htmx-request > .h-loading, .h-loading.htmx-request) {
    display: block;
  }

  .h-loading::before,
  .h-loading::after {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
  }

  .h-loading::before {
    background: var(--accent-tint-2);
  }

  .h-loading::after {
    width: 40%;
    background: var(--accent);
    animation: h-loading 1.4s ease-in-out infinite;
  }

  .h-skeleton {
    display: grid;
    gap: 10px;
    animation:
      h-reveal 0s 300ms backwards,
      h-pulse 1.6s ease-in-out 300ms infinite;
  }

  .h-skeleton-line {
    height: 0.75em;
    border-radius: 4px;
    background: var(--fill-0);
  }

  @keyframes h-loading {
    from {
      transform: translateX(-100%);
    }

    to {
      transform: translateX(250%);
    }
  }

  @keyframes h-reveal {
    from {
      visibility: hidden;
    }
  }

  @keyframes h-pulse {
    50% {
      opacity: 0.55;
    }
  }

  /* Empty state */
  .h-empty {
    display: flex;
    align-items: center;
    gap: var(--space-4);
  }

  .h-empty--action {
    flex-direction: column;
    align-items: flex-start;
  }

  .h-mascot {
    flex: none;
    width: 72px;
    height: 72px;
    border-radius: var(--radius);
    background: var(--fill-2);
  }

  .h-empty-text {
    display: grid;
    gap: var(--space-1);
    max-width: 56ch;
    overflow-wrap: anywhere;
  }

  .h-empty-title {
    color: var(--ink-1);
    font-size: var(--text-body);
    font-weight: 600;
  }

  .h-empty-title h2 {
    font-size: 1.375rem;
  }

  .h-empty-help {
    color: var(--ink-4);
    font-size: 0.875rem;
  }

  /* Text roles shared by the cards below */
  .h-meta {
    color: var(--meta);
    font-size: 0.75rem;
    font-weight: 400;
  }

  /* Programs sets secondary lines at the issue's 13px, in a gray that keeps
     4.5:1 on a row's fill. */
  :is(.h-programs, .h-card--bordered) .h-meta {
    color: var(--ink-4);
    font-size: var(--text-meta);
  }

  .h-overline {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: var(--tracking-overline);
    text-transform: uppercase;
  }

  /* A name over its secondary line. */
  .h-lines {
    display: grid;
    flex: 1;
    gap: 2px;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .h-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
  }

  /* A head whose text may run to several lines, with its actions at the top. */
  .h-card-head--top {
    align-items: flex-start;
    gap: var(--space-2);
  }

  .h-card-more {
    font-size: 0.875rem;
  }

  /* Home: the greeting, the banner, then the calendar and Upcoming programs
     beside the notes panel. The panel's rail widens the calendar. */
  .h-greeting {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 14px;
  }

  .h-greeting p {
    color: var(--ink-4);
  }

  .h-home {
    display: grid;
    flex: 1;
    grid-template-columns: minmax(0, 1fr) var(--notes-panel);
    grid-template-rows: 1fr auto;
    gap: var(--space-4);
    transition: grid-template-columns 0.2s ease;
  }

  .h-home:has(> .h-notes--collapsed) {
    grid-template-columns: minmax(0, 1fr) var(--space-16);
  }

  .h-home-calendar {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .h-upcoming {
    grid-column: 1;
    grid-row: 2;
    gap: var(--space-3);
    padding-block: 18px;
    container: upcoming / inline-size;
  }

  .h-upcoming-row .h-capacity {
    flex: none;
    inline-size: 340px;
    gap: var(--space-5);
  }

  .h-upcoming-row .h-capacity-meter {
    flex: none;
    inline-size: 150px;
    min-inline-size: 0;
  }

  .h-upcoming-row .h-tag {
    margin-inline-start: auto;
  }

  .h-upcoming-name {
    display: grid;
    gap: 2px;
    min-width: 0;
  }

  .h-upcoming-title {
    color: var(--ink-1);
    font-weight: 600;
  }

  /* A program's name, and its dates and site, each keep to one line, and end
     in an ellipsis rather than run under the capacity beside them. */
  .h-upcoming-name > * {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Too narrow for 12rem of name beside the capacity's 340px, the gap and the
     row's padding, a row puts its capacity under the name, across the row. */
  @container upcoming (max-width: 36rem) {
    .h-upcoming-row {
      flex-direction: column;
      align-items: stretch;
      gap: var(--space-3);
    }

    .h-upcoming-row .h-capacity {
      inline-size: auto;
    }

    .h-upcoming-row .h-capacity-meter {
      flex: 1;
      inline-size: auto;
    }
  }

  /* RegistrationOpenBanner: Hutch's accent, whatever the client brand. */
  .h-registration {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius);
    background: var(--accent-tint);
    box-shadow:
      0 1px 2px rgba(140, 71, 32, 0.08),
      0 6px 18px rgba(140, 71, 32, 0.08);
  }

  .h-registration-tile {
    display: grid;
    flex: none;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--paper);
  }

  .h-registration-tile .h-icon {
    width: 22px;
    height: 22px;
  }

  .h-registration-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
  }

  .h-registration-overline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    color: var(--accent-ink);
    font-size: var(--text-meta);
  }

  .h-registration-site {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-weight: 600;
  }

  .h-registration-site .h-icon {
    width: 14px;
    height: 14px;
  }

  .h-registration-headline {
    color: var(--ink-1);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
  }

  .h-registration-progress {
    display: grid;
    flex: none;
    gap: 6px;
    inline-size: 220px;
    color: var(--ink-3);
    font-size: var(--text-meta);
  }

  .h-registration-progress strong {
    color: var(--ink-1);
  }

  .h-registration-bar {
    height: 8px;
    overflow: hidden;
    border-radius: 4px;
    background: var(--accent-tint-2);
  }

  .h-registration-bar::after {
    content: "";
    display: block;
    width: var(--h-filled, 0%);
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
  }

  .h-registration-actions {
    display: flex;
    flex: none;
    gap: var(--space-2);
  }

  .h-registration-more {
    color: var(--accent-ink);
    font-size: var(--text-meta);
    font-weight: 600;
  }

  /* NotesPanel: the tabs and their content, or only the rail. Its content
     never sizes Home's grid, which would push Upcoming programs off the
     screen; a long panel scrolls instead. */
  .h-notes {
    grid-column: 2;
    grid-row: 1 / span 2;
    gap: 14px;
    min-height: 0;
    padding: var(--space-4);
    overflow: auto;
    contain: size;
  }

  .h-notes-open {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .h-notes-rail,
  .h-notes--collapsed .h-notes-open {
    display: none;
  }

  .h-notes--collapsed .h-notes-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 2px 0;
    border: 0;
    background: transparent;
    cursor: pointer;
  }

  .h-notes-rail-tile,
  .h-notes-rail-chevron {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
  }

  .h-notes-rail-tile {
    position: relative;
    background: var(--tile-calendar);
    color: var(--paper);
  }

  .h-notes-rail-tile .h-badge {
    position: absolute;
    top: -5px;
    right: -6px;
    box-shadow: 0 0 0 2px var(--paper);
  }

  .h-notes-rail-chevron {
    background: var(--fill-1);
    color: var(--ink-4);
  }

  .h-notes-rail .h-icon {
    width: 16px;
    height: 16px;
  }

  .h-notes-head {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .h-notes-head .h-segmented {
    display: flex;
    flex: 1;
    min-width: 0;
  }

  .h-notes-head .h-segment {
    flex: 1;
    min-height: 34px;
    padding: 0 var(--space-2);
    font-size: var(--text-meta);
    white-space: nowrap;
  }

  .h-notes-fold {
    display: grid;
    flex: none;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink-4);
    cursor: pointer;
  }

  .h-notes-fold:hover {
    background: var(--fill-1);
  }

  .h-notes-more {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 6px;
    font-size: 0.875rem;
  }

  .h-notes-more .h-icon {
    width: 16px;
    height: 16px;
  }

  .h-message,
  .h-note {
    display: flex;
    gap: var(--space-3);
    padding: 14px;
    border-radius: var(--radius);
    background: var(--fill-0);
  }

  .h-message--unread {
    background: var(--accent-tint);
  }

  .h-message .h-avatar {
    width: 34px;
    height: 34px;
    background: var(--paper);
  }

  .h-message-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
  }

  .h-message-head {
    display: flex;
    justify-content: space-between;
    gap: var(--space-2);
  }

  .h-message-name {
    color: var(--ink-1);
    font-size: 0.875rem;
    font-weight: 600;
  }

  .h-message-body {
    margin-top: var(--space-1);
    color: var(--ink-2);
    font-size: 0.875rem;
    line-height: 1.45;
  }

  .h-tip {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius);
    background: var(--fill-0);
  }

  .h-tip h3 {
    color: var(--ink-1);
    font-size: 1.0625rem;
  }

  .h-tip p {
    color: var(--ink-2);
    font-size: 0.875rem;
  }

  .h-tip .h-button {
    align-self: flex-start;
  }

  .h-note-check {
    flex: none;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    border-radius: 5px;
    background: var(--paper);
    box-shadow: inset 0 0 0 1.5px var(--line);
  }

  .h-note-text {
    display: grid;
    gap: var(--space-1);
    color: var(--ink-1);
    font-size: 0.875rem;
    line-height: 1.45;
  }

  /* Touch, and a phone: hit targets of at least 44px, and taller buttons. */
  @media (pointer: coarse), (max-width: 720px) {
    .h-segment,
    .h-chip {
      min-height: 44px;
    }

    .h-button {
      min-height: 48px;
    }
  }

  /* For screen readers alone. */
  .h-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    border: 0;
    white-space: nowrap;
  }

  .h-icon-button {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink-3);
    cursor: pointer;
  }

  .h-icon-button:hover {
    background: var(--fill-1);
    color: var(--ink-1);
    text-decoration: none;
  }

  /* A wrapper around what only a phone shows. */
  .h-phone-only {
    display: none;
  }

  /* A ••• menu: the sheet beside the button that opens it. */
  .h-popover {
    position: relative;
  }

  .h-popover-menu {
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    padding: 6px;
    border: 1px solid var(--line-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-menu);
  }

  /* Programs: the list beside the class drawer. The drawer wraps under the
     list wherever the two do not fit, and the list takes the whole width while
     the drawer is closed. */
  .h-shell--page-row .h-main {
    padding: var(--space-8) var(--space-8) 48px;
  }

  .h-programs {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-6);
  }

  .h-programs-list {
    flex: 999 1 580px;
    min-width: 0;
  }

  .h-search {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 320px;
    max-width: 100%;
    height: 40px;
    padding: 0 var(--space-3);
    border-radius: var(--radius);
    background: var(--fill-1);
    color: var(--meta);
  }

  .h-search:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .h-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--ink);
    font-size: 0.875rem;
  }

  /* --meta falls short of 4.5:1 on the field's fill. */
  .h-search input::placeholder {
    color: var(--ink-4);
  }

  /* A swap of the whole list shows two cards in its place after 300ms, with no
     shimmer. */
  .h-programs-list > .h-skeleton {
    display: none;
    animation: h-reveal 0s 300ms backwards;
  }

  .h-programs-list.htmx-request > .h-skeleton {
    display: grid;
  }

  .h-programs-list.htmx-request > #programs-content {
    animation: h-conceal 0s 300ms forwards;
  }

  @keyframes h-conceal {
    to {
      visibility: hidden;
      height: 0;
      overflow: hidden;
    }
  }

  /* Select mode hides what is about the list as a whole. */
  [data-selecting] .h-overview {
    display: none;
  }

  .h-overview h2,
  .h-divider h2 {
    font-size: var(--text-body);
    letter-spacing: 0;
  }

  .h-divider {
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px solid var(--line);
  }

  .h-dot {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--risk-mark);
  }

  .h-dot--idle {
    background: transparent;
    box-shadow: inset 0 0 0 2px var(--disabled);
  }

  /* A site card */
  .h-site-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }

  .h-site-line h2 {
    min-width: 0;
  }

  .h-site-kind {
    display: grid;
    flex: none;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: var(--fill-1);
    color: var(--ink-4);
  }

  [data-reorder-handle] {
    cursor: grab;
  }

  [data-reorder-dragging] {
    opacity: 0.5;
  }

  /* A move that leads nowhere is no option. */
  [data-reorder] > :first-child [data-reorder-move="up"],
  [data-reorder] > :last-child [data-reorder-move="down"] {
    display: none;
  }

  /* A class row: its bar and tag columns line up from row to row. */
  .h-class {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px minmax(0, 180px);
    gap: var(--space-5);
    min-height: 56px;
  }

  .h-class:is([aria-current="true"], [aria-pressed="true"]) {
    background: var(--paper);
    box-shadow: inset 0 0 0 2px var(--accent);
  }

  .h-class[aria-pressed="true"] {
    box-shadow: inset 0 0 0 2px var(--ink-1);
  }

  .h-class-name {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
  }

  .h-class-check {
    display: none;
    flex: none;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 0 1.5px var(--disabled);
    color: var(--paper);
  }

  [data-selecting] .h-class-check {
    display: grid;
  }

  .h-class[aria-pressed="true"] .h-class-check {
    background: var(--ink-1);
    box-shadow: none;
  }

  /* An open disclosure's chevron points back up. */
  [aria-expanded="true"] > .h-icon {
    transform: rotate(180deg);
  }

  .h-bulk {
    position: sticky;
    bottom: var(--space-4);
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
    border-radius: var(--radius-lg);
    background: var(--ink-1);
    box-shadow: var(--shadow-float);
    color: var(--paper);
  }

  .h-bulk b {
    flex: 1 1 160px;
  }

  /* Out of sight while empty, and in the accessibility tree all the time, so
     that a screen reader announces what lands in it. */
  .h-toast {
    position: fixed;
    bottom: var(--space-6);
    left: 50%;
    z-index: 30;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-card);
    background: var(--ink-1);
    box-shadow: var(--shadow-float);
    color: var(--paper);
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    transform: translateX(-50%);
    pointer-events: none;
  }

  .h-toast:empty {
    opacity: 0;
  }

  /* The class drawer. show() leaves it a panel beside the list, and showModal()
     makes it a bottom sheet. It scrolls on its own, under a pinned head. */
  [data-drawer-slot] {
    display: contents;
  }

  .h-drawer {
    position: sticky;
    top: calc(var(--topbar) + var(--space-6));
    flex: 1 1 380px;
    max-width: 420px;
    max-height: calc(100vh - var(--topbar) - 48px);
    margin: 0;
    padding: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--paper);
    box-shadow: var(--shadow-sheet);
    color: inherit;
  }

  .h-drawer:modal {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    max-height: 88vh;
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  }

  .h-drawer::backdrop {
    background: rgba(28, 28, 28, 0.45);
  }

  .h-drawer-head {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: var(--space-6) var(--space-6) var(--space-3);
    background: var(--paper);
    box-shadow: 0 1px 0 var(--fill-2);
  }

  .h-sheet-grab {
    display: none;
    width: 40px;
    height: 4px;
    margin: 0 auto var(--space-3);
    border-radius: 2px;
    background: var(--line);
  }

  .h-drawer:modal .h-sheet-grab {
    display: block;
  }

  .h-drawer-body {
    gap: var(--space-8);
    padding: var(--space-5) var(--space-6) calc(var(--space-6) + env(safe-area-inset-bottom));
  }

  .h-dates {
    flex-flow: row wrap;
  }

  .h-saved {
    min-height: 1.25rem;
  }

  /* Phone: under 720px the sidebar becomes a bottom tab bar on every page. A
     page with its own row (Programs) drops the top bar too. */
  @media (max-width: 720px) {
    .h-shell {
      grid-template-rows: auto 1fr;
      grid-template-columns: minmax(0, 1fr);
    }

    .h-shell--page-row {
      grid-template-rows: 1fr;
    }

    .h-shell--page-row .h-topbar {
      display: none;
    }

    .h-sidebar,
    .h-shell--collapsed .h-sidebar {
      position: fixed;
      inset: auto 0 0;
      z-index: 5;
      grid-row: auto;
      flex-direction: row;
      width: 100%;
      height: auto;
      padding: var(--space-1) var(--space-2) calc(var(--space-1) + env(safe-area-inset-bottom));
      box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.08);
    }

    .h-sidebar .h-brand,
    .h-collapse {
      display: none;
    }

    .h-nav {
      flex-direction: row;
      width: 100%;
    }

    .h-nav-item,
    .h-shell--collapsed .h-nav-item {
      flex: 1 1 0;
      flex-direction: column;
      justify-content: center;
      gap: 2px;
      height: 56px;
      padding: 6px var(--space-1);
      font-size: 0.75rem;
    }

    .h-shell--collapsed .h-sidebar :is(.h-brand-name, .h-sidebar-label) {
      opacity: 1;
    }

    .h-main,
    .h-shell--page-row .h-main {
      padding: var(--space-3) var(--space-4) calc(84px + env(safe-area-inset-bottom));
    }

    h1 {
      font-size: 1.375rem;
    }

    .h-button {
      min-height: 44px;
    }

    .h-icon-button {
      width: 44px;
      height: 44px;
    }

    .h-menu-item {
      min-height: 44px;
    }

    .h-tag,
    .h-segment {
      white-space: normal;
    }

    .h-card--bordered {
      padding: var(--space-4);
    }

    /* The site's forward action drops to a full-width line of its own. */
    .h-card-head--top {
      flex-wrap: wrap;
    }

    .h-card-head--top > .h-button {
      flex: 1 1 100%;
      order: 1;
    }

    /* The badge drops to a line of its own, under the name. */
    .h-site-line h2 {
      flex: 1 1 calc(100% - 64px);
    }

    .h-class {
      grid-template-columns: minmax(0, 1fr) auto;
      gap: var(--space-2) var(--space-3);
    }

    .h-class-name {
      grid-column: 1 / -1;
    }

    .h-class > :not(.h-class-name) {
      display: contents;
    }

    .h-class .h-tag {
      justify-self: start;
    }

    /* The phone's search opens under the page row, as wide as the row. */
    .h-page-row {
      position: relative;
    }

    .h-page-row:has(.h-phone-search[open]) {
      margin-bottom: 52px;
    }

    .h-phone-search > .h-search {
      position: absolute;
      inset: calc(100% + var(--space-2)) 0 auto;
      width: auto;
      background: var(--paper);
      box-shadow: var(--shadow-chip);
    }

    .h-search input,
    .h-field > input {
      font-size: 1rem;
    }

    .h-bulk {
      bottom: calc(76px + env(safe-area-inset-bottom));
    }

    .h-toast {
      bottom: calc(88px + env(safe-area-inset-bottom));
    }

    .h-phone-only {
      display: contents;
    }

    .h-wide-only {
      display: none;
    }
  }
}
