/* ==========================================================================
   Soft UI - the portable core of the CaseTasks look, in one file.

   Friendly and rounded: Nunito throughout, pill buttons and tags, big-radius
   white cards with soft blue-tinted shadows on a light blue page. Color comes
   from tinted fills, never from a single colored edge.

   WHAT IS IN HERE
     1. Tokens (light + dark)        6. Tags, avatars
     2. Base                         7. Menus, dialogs, toasts
     3. App shell: nav bar, page     8. Stats, progress, detail header
     4. Page furniture, cards        9. Lists (rows)
     5. Buttons and forms           10. Sign-in, error page, phone menu

   HOW TO USE IT
     1. Link this file. The font is pulled in by the @import below; for a
        faster first paint, delete that line and put this in <head> instead:
          <link rel="preconnect" href="https://fonts.googleapis.com">
          <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
          <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@500;600;700;800;900&display=swap" rel="stylesheet">
     2. Put this in <head>, before the stylesheet, so the theme is set before
        the first paint (no flash):
          <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
          <meta name="color-scheme" content="light dark">
          <script>(function(){var r=document.documentElement,p;try{p=localStorage.getItem('theme')||'system'}catch(e){p='system'}var d=p==='dark'||(p==='system'&&matchMedia('(prefers-color-scheme: dark)').matches);r.setAttribute('data-theme',d?'dark':'light');r.setAttribute('data-theme-pref',p)})();</script>
     3. Load soft-ui.js at the end of <body>. It runs the light/dark switch,
        the menus, the phone menu, dialogs and toasts. (If you only carried
        this stylesheet, the same script is in the comment at the very bottom.)
     4. soft-ui-demo.html beside this file shows the markup for every piece,
        and README.md explains the rest.

   RULES OF THE HOUSE
     - Components only use the tokens below. Rebrand by changing --primary and
       its relatives in both blocks; nothing else needs touching.
     - Dark mode is [data-theme="dark"] on <html>.
     - Breakpoints: 640 / 900 / 1100. Phone first; 900 is where the nav bar
       becomes the floating pill and lists become one-line rows.
     - Icons are inline SVGs with class="icon", drawn with stroke="currentColor".
     - Every tap target is at least 44px.
   ========================================================================== */
@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@500;600;700;800;900&display=swap");

/* ==========================================================================
   1. Tokens
   ========================================================================== */
:root {
  --font: "Nunito", "Segoe UI", system-ui, Arial, sans-serif;

  --bg: #eaf0fa;
  --surface: #ffffff;
  --surface-2: #f3f7fd;       /* rows and wells inside a card */
  --surface-3: #e6eefb;       /* tinted controls */
  --field: #ffffff;
  --text: #14223b;
  --text-2: #53617a;
  --text-3: #64718a;
  --border: #e1e8f4;
  --border-strong: #b9c9e6;

  --primary: #1156b0;
  --on-primary: #ffffff;
  --primary-text: #1156b0;    /* primary used as text or an icon on a surface */
  --primary-soft: #dbe7fb;
  --primary-mid: #8fb6ee;     /* the "current step" part of a progress bar */

  --success: #1d7a4c;
  --on-success: #ffffff;
  --success-soft: #dcf3e6;
  --warning: #7a4b00;
  --warning-soft: #fff0cf;
  --danger: #b42318;
  --on-danger: #ffffff;
  --danger-soft: #fde0e0;

  --shadow: 0 4px 16px rgba(40, 80, 150, .08);
  --shadow-md: 0 8px 24px rgba(40, 80, 150, .14);
  --shadow-lg: 0 24px 60px rgba(20, 40, 90, .26);
  --shadow-btn: 0 6px 14px rgba(17, 86, 176, .28);
  --scrim: rgba(20, 34, 59, .45);

  --radius: 22px;             /* cards */
  --radius-md: 14px;          /* rows, inputs */
  --pill: 999px;
  --ring: 0 0 0 4px rgba(17, 86, 176, .28);
  --topbar-h: 60px;
  --gutter: 16px;
  --page-max: 1280px;

  /* The logo, as a one-color image used as a mask so the theme picks its color.
     Set these to your own files (use a path from the site root):
       --brand-mark: url("/static/img/emblem-white.png");   square-ish, in the nav bar
       --brand-logo: url("/static/img/logo-white.png");     wide, on the sign-in page
       --brand-logo-ratio: 540 / 241;                       that wide logo's width / height */
}

:root[data-theme="dark"] {
  --bg: #0e1626;
  --surface: #18233a;
  --surface-2: #1f2c47;
  --surface-3: #283857;
  --field: #121b2f;
  --text: #eef3fb;
  --text-2: #b7c3d8;
  --text-3: #93a1ba;
  --border: #2a3855;
  --border-strong: #46597f;

  --primary: #2f73d6;
  --on-primary: #ffffff;
  --primary-text: #9cc3ff;
  --primary-soft: rgba(110, 168, 255, .2);
  --primary-mid: #5f84bd;

  --success: #5ad69a;
  --on-success: #0e1626;
  --success-soft: rgba(90, 214, 154, .16);
  --warning: #ffcf7a;
  --warning-soft: rgba(255, 186, 67, .17);
  --danger: #ff9a92;
  --on-danger: #0e1626;
  --danger-soft: rgba(255, 120, 110, .17);

  --shadow: 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
  --shadow-btn: 0 6px 14px rgba(0, 0, 0, .35);
  --scrim: rgba(4, 8, 16, .7);
  --ring: 0 0 0 4px rgba(156, 195, 255, .4);
}

/* Accent colors for labelling kinds of things, used as a tinted label
   (see .label-tone). Put the class on the item or any parent. */
.tone-blue { --tone: #1156b0; }
.tone-violet { --tone: #5b3d9a; }
.tone-teal { --tone: #0c6b66; }
.tone-amber { --tone: #9a4a12; }
.tone-rose { --tone: #a3123a; }
.tone-slate { --tone: #4b5870; }
[data-theme="dark"] .tone-blue { --tone: #9cc3ff; }
[data-theme="dark"] .tone-violet { --tone: #c3b0f0; }
[data-theme="dark"] .tone-teal { --tone: #6fd8cd; }
[data-theme="dark"] .tone-amber { --tone: #ffc98a; }
[data-theme="dark"] .tone-rose { --tone: #ffa3b8; }
[data-theme="dark"] .tone-slate { --tone: #bcc8da; }

/* ==========================================================================
   2. Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 32px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  font: 500 1rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex; flex-direction: column;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3 { color: var(--text); font-family: var(--font); font-weight: 900; }
h1 { font-size: clamp(1.75rem, 1.3rem + 1.9vw, 2.25rem); line-height: 1.15; letter-spacing: -.01em; }
h2 { font-size: 1.1875rem; line-height: 1.25; }
h3 { font-size: 1.0625rem; line-height: 1.3; font-weight: 800; }
a { color: inherit; text-decoration: none; }
b, strong { font-weight: 800; color: var(--text); }
img { max-width: 100%; }
code { font: .875em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-3); padding: 2px 7px; border-radius: 8px; color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
.icon { flex: none; vertical-align: middle; }
[hidden] { display: none !important; }
mark { padding: 0 3px; margin: 0 -1px; border-radius: 6px; background: #ffe066; color: #14223b; font-weight: 900; }

/* Focus is a soft ring, never an outline. Round controls restate their radius. */
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 10px; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 10px; left: 10px; z-index: 200; padding: 12px 20px; background: var(--primary); color: var(--on-primary); border-radius: var(--pill); font-weight: 800; transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Show one thing in light mode and another in dark (the sun and the moon). */
.when-dark { display: none; }
.when-light { display: inline-flex; }
[data-theme="dark"] .when-dark { display: inline-flex; }
[data-theme="dark"] .when-light { display: none; }

/* Show something only on phones, or only from 900px up. */
@media (max-width: 899px) { .only-desktop { display: none !important; } }
@media (min-width: 900px) { .only-mobile, .mobile-scrim { display: none !important; } }

/* ==========================================================================
   3. App shell: a plain bar on phones, a floating white pill from 900px up
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h);
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
  background: var(--surface);
  box-shadow: var(--shadow);
}
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; min-height: 44px; margin-right: 10px; border-radius: var(--pill); }
.brand-logo {
  flex: none; width: 42px; height: 38px; background: var(--primary);
  -webkit-mask: var(--brand-mark, none) center / contain no-repeat;
  mask: var(--brand-mark, none) center / contain no-repeat;
}
[data-theme="dark"] .brand-logo { background: #ffffff; }
.brand-name { color: var(--text); font-weight: 900; font-size: 1.1875rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: none; align-items: center; gap: 4px; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px;
  padding: 0 16px; border-radius: var(--pill); color: var(--text-2); font-weight: 700; font-size: .9375rem;
  transition: background-color .2s, color .2s;
}
.tab:hover { background: var(--surface-3); color: var(--text); }
.tab.is-active { background: var(--primary); color: var(--on-primary); }
.tab:focus-visible { border-radius: var(--pill); }
/* A number beside a tab's name: <span class="tab-badge"><b>3</b></span> */
.tab-badge b {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--pill); background: #ffe2a8; color: #6b4300; font-size: .75rem; font-weight: 800; font-variant-numeric: tabular-nums;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.page {
  width: 100%; max-width: var(--page-max); margin: 0 auto;
  padding: 22px var(--gutter) calc(env(safe-area-inset-bottom) + 36px);
  display: flex; flex-direction: column; gap: 18px;
}
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.page-narrow { max-width: 780px; }

@media (max-width: 479px) {
  .topbar { gap: 6px; }
  .topbar .brand { gap: 8px; margin-right: 0; }
  .topbar .brand-name { font-size: 1rem; }
  .topbar-actions { gap: 0; flex: none; }
}
@media (max-width: 369px) { .topbar .brand-name { font-size: .9375rem; } }

@media (min-width: 900px) {
  :root { --gutter: 28px; }
  /* Only the white pill is drawn; the strip around it is see-through, so the
     page shows past its rounded ends as it scrolls. The strip itself ignores
     the mouse so it never blocks what is behind it. */
  .topbar {
    isolation: isolate;
    height: calc(var(--topbar-h) + 28px);
    padding: 16px max(calc(var(--gutter) + 10px), calc((100% - var(--page-max)) / 2 + 10px)) 12px max(calc(var(--gutter) + 20px), calc((100% - var(--page-max)) / 2 + 20px));
    background: transparent; box-shadow: none; pointer-events: none;
  }
  .topbar > * { pointer-events: auto; align-self: stretch; }
  .topbar::before {
    content: ""; position: absolute; z-index: -1; top: 16px; left: 50%; transform: translateX(-50%);
    width: calc(100% - var(--gutter) * 2); max-width: var(--page-max); height: var(--topbar-h);
    background: var(--surface); border-radius: var(--pill); box-shadow: var(--shadow-md);
  }
  .tabs { display: flex; flex: 1; }
  .page { padding-top: 20px; padding-bottom: 64px; gap: 22px; }
  .stack { gap: 22px; }
}

/* A credit at the foot of every page; margin-top: auto keeps it at the bottom. */
.site-foot { margin-top: auto; padding: 8px var(--gutter) calc(env(safe-area-inset-bottom) + 22px); text-align: center; }
.provided-by { display: inline-block; padding: 6px 12px; border-radius: 14px; line-height: 1.2; opacity: .7; transition: opacity .2s; }
.provided-by:hover, .provided-by:focus-visible { opacity: 1; }
.provided-by-label { color: var(--text-3); font-size: .6875rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.provided-by img { height: 28px; width: auto; margin-top: 6px; vertical-align: top; }

/* ==========================================================================
   4. Page furniture and cards
   ========================================================================== */
.eyebrow { display: block; color: var(--text-2); font-size: .9375rem; font-weight: 700; margin-bottom: 2px; }
/* A tinted tag in a .tone-* color. */
.label-tone { display: inline-block; align-self: flex-start; padding: 4px 11px; border-radius: var(--pill); background: color-mix(in srgb, var(--tone, var(--primary-text)) 13%, var(--surface)); color: var(--tone, var(--primary-text)); font-size: .8125rem; line-height: 1.2; font-weight: 800; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; }
.page-sub { margin-top: 4px; max-width: 60ch; }
.page-sub .icon { margin-right: 6px; vertical-align: -2px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; max-width: 100%; }
.toolbar > * { max-width: 100%; }
.section-head, .card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-head { margin-bottom: 12px; }
.section-head h2 { font-size: 1.375rem; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: .9375rem; font-weight: 700; margin-bottom: -6px; }
.crumbs a { color: var(--primary-text); padding: 6px 0; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { color: var(--primary-text); font-weight: 800; font-size: .9375rem; display: inline-flex; align-items: center; gap: 4px; }
.link .icon { transition: transform .2s; }
.link:hover { text-decoration: underline; }
.link:hover .icon { transform: translateX(3px); }
.hint { color: var(--text-3); font-size: .875rem; line-height: 1.45; display: inline-flex; align-items: flex-start; gap: 6px; }
.hint .icon { margin-top: 2px; }
.hint-warn { color: var(--warning); }
.count { display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 9px; border-radius: var(--pill); background: var(--surface-3); color: var(--primary-text); font-size: .8125rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.subhead { margin: 22px 0 8px; color: var(--text-2); font-size: .9375rem; font-weight: 800; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card-head { margin-bottom: 14px; flex-wrap: wrap; }
.card-title { font-size: 1.5rem; line-height: 1.2; }
.card-foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
@media (min-width: 900px) { .card { padding: 24px; } }

/* Two columns from 1100px up: the main one, and a narrower one beside it. */
.split { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .split { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 22px; align-items: start; } }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 26px 12px; }
.empty-icon { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); margin-bottom: 8px; }
.empty-title { font-weight: 900; font-size: 1.125rem; color: var(--text); }
.empty-text { max-width: 44ch; }
.empty .btn { margin-top: 12px; }

/* Label and value pairs: <dl class="details"><div><dt>..</dt><dd>..</dd></div></dl> */
.details { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.details dt { color: var(--text-3); font-size: .875rem; font-weight: 700; margin-bottom: 2px; }
.details dd { color: var(--text); font-weight: 800; overflow-wrap: anywhere; }
.details-wide { grid-column: 1 / -1; }
.details-wide dd { font-weight: 600; }

/* A tinted notice inside a card. */
.notice { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: 16px; background: var(--surface-3); color: var(--text); line-height: 1.45; }
.notice .icon { flex: none; margin-top: 2px; color: var(--text-3); }
.notice-warning { background: var(--warning-soft); }
.notice-warning .icon { color: var(--warning); }
.notice-danger { background: var(--danger-soft); }
.notice-danger .icon { color: var(--danger); }

/* ==========================================================================
   5. Buttons and forms
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border: 0; border-radius: var(--pill);
  background: var(--primary-soft); color: var(--primary-text);
  font-weight: 800; font-size: .9375rem; line-height: 1.2; white-space: nowrap;
  transition: background-color .2s, box-shadow .2s, transform .15s, filter .2s;
}
.btn:hover { filter: brightness(.96); transform: translateY(-1px); }
[data-theme="dark"] .btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.98); }
.btn:focus-visible { border-radius: var(--pill); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-btn); }
.btn-primary:hover, [data-theme="dark"] .btn-primary:hover { filter: brightness(1.1); }
.btn-success { background: var(--success); color: var(--on-success); box-shadow: 0 6px 14px rgba(29, 122, 76, .24); }
.btn-success:hover, [data-theme="dark"] .btn-success:hover { filter: brightness(1.08); }
.btn-danger { background: var(--danger); color: var(--on-danger); box-shadow: 0 6px 14px rgba(180, 35, 24, .22); }
.btn-danger:hover, [data-theme="dark"] .btn-danger:hover { filter: brightness(1.08); }
.btn-outline { background: var(--surface); color: var(--primary-text); box-shadow: inset 0 0 0 2px var(--primary-soft); }
.btn-ghost { background: var(--surface-3); color: var(--primary-text); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); filter: none; }
.btn-quiet { background: transparent; color: var(--text-3); box-shadow: inset 0 0 0 1.5px var(--border); font-weight: 700; }
.btn-quiet:hover { color: var(--text-2); background: var(--surface-2); filter: none; transform: none; }
.btn-placeholder { visibility: hidden; }  /* keeps a button's room when a row has no use for it */
.btn-sm { min-height: 36px; padding: 0 14px; font-size: .875rem; }
.btn-block { width: 100%; }
.is-busy { opacity: .6; pointer-events: none; }
@media (pointer: coarse) { .btn-sm { min-height: 44px; } }

.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); transition: background-color .2s, color .2s; }
.icon-btn:hover { background: var(--surface-3); color: var(--primary-text); }
.icon-btn:focus-visible { border-radius: 50%; }

/* A switch between a few views: one white pill holding the choices. */
.seg-control { display: inline-flex; gap: 2px; max-width: 100%; padding: 4px; border-radius: var(--pill); background: var(--surface); box-shadow: var(--shadow); overflow-x: auto; scrollbar-width: none; }
.seg-control::-webkit-scrollbar { display: none; }
.seg-btn { display: inline-flex; flex: none; align-items: center; gap: 6px; min-height: 36px; padding: 0 16px; border: 0; border-radius: var(--pill); background: transparent; color: var(--text-2); font-weight: 800; font-size: .875rem; transition: background-color .2s, color .2s; }
.seg-btn:hover { color: var(--text); background: var(--surface-2); }
.seg-btn.is-active { background: var(--primary); color: var(--on-primary); }
.seg-btn:focus-visible { border-radius: var(--pill); }
@media (pointer: coarse) { .seg-btn { min-height: 40px; } }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; border: 0; padding: 0; }
.field label, .field legend { color: var(--text); font-weight: 800; font-size: .9375rem; padding: 0; }
.field label .hint { font-weight: 600; }
.req { color: var(--danger); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 16px;
  background-color: var(--field); color: var(--text); font-weight: 600;
  border: 2px solid var(--border); border-radius: var(--radius-md);
  transition: border-color .2s, box-shadow .2s;
}
textarea { resize: vertical; line-height: 1.5; }
select { cursor: pointer; appearance: none; padding-right: 40px; 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='%2364718a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; }
[data-theme="dark"] select { 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='%2393a1ba' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; font-weight: 500; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--primary); box-shadow: var(--ring); border-radius: var(--radius-md); }
input[readonly] { background-color: var(--surface-2); color: var(--text-2); }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { color-scheme: dark; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 700; color: var(--text); }
.check input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
/* Search boxes and filters in a toolbar: pill-shaped, lifted, no border. */
.filter select, .filter input { min-width: 190px; border-color: transparent; box-shadow: var(--shadow); border-radius: var(--pill); min-height: 44px; }
.filter select:focus-visible, .filter input:focus-visible { border-radius: var(--pill); border-color: var(--primary); }
.filter select { max-width: 280px; text-overflow: ellipsis; }
.form-grid { display: grid; gap: 0 18px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .field-wide { grid-column: 1 / -1; } }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.form-actions-inline { justify-content: flex-start; margin-top: 8px; }
.form-actions-center { justify-content: center; }
@media (max-width: 639px) { .form-actions .btn { flex: 1; } }
.fieldset-plain { margin: 0; padding: 0; border: 0; min-width: 0; }
.fieldset-plain:disabled { opacity: .5; }
.fieldset-plain:disabled * { cursor: not-allowed; }

/* Pick one of three, as big tiles (the Light / Dark / System choice). */
.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-option { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 92px; padding: 16px 8px; border: 0; border-radius: 20px; background: var(--surface-2); color: var(--text-2); font-weight: 800; font-size: .9375rem; text-align: center; transition: background-color .2s, color .2s, box-shadow .2s; }
.theme-option:hover { color: var(--text); background: var(--surface-3); }
.theme-option[aria-checked="true"] { background: var(--primary-soft); color: var(--primary-text); box-shadow: inset 0 0 0 2px var(--primary); }
.theme-option:focus-visible { border-radius: 20px; }
/* A settings page: what it is on the left, its control on the right. */
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px 20px; flex-wrap: wrap; padding: 18px 0; }
.setting-row + .setting-row { border-top: 1px solid var(--border); }
.setting-row:first-child, .card-head + .setting-row { padding-top: 0; }
.setting-row:last-child { padding-bottom: 0; }
.setting-row > div:first-child { flex: 1 1 280px; }
.setting-row h3 { margin-bottom: 4px; }

/* ==========================================================================
   6. Tags and avatars
   ========================================================================== */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: var(--pill); font-size: .8125rem; line-height: 1.1; font-weight: 800; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.pill-primary { background: var(--primary-soft); color: var(--primary-text); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
/* A date tag. Add -warning when it is close and -danger when it is late;
   -muted is plain text. As a <button> it lifts on hover. */
.due { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: var(--pill); background: var(--surface-3); color: var(--primary-text); font-size: .8125rem; line-height: 1.1; font-weight: 800; white-space: nowrap; }
.due-muted { padding: 0; background: transparent; color: var(--text-3); font-weight: 600; white-space: normal; line-height: 1.4; }
.due-warning { background: var(--warning-soft); color: var(--warning); }
.due-danger { background: var(--danger-soft); color: var(--danger); }
button.due { position: relative; z-index: 1; border: 0; font-family: inherit; transition: filter .2s, transform .15s; }
button.due:hover { filter: brightness(.95); transform: translateY(-1px); }
[data-theme="dark"] button.due:hover { filter: brightness(1.15); }
button.due:focus-visible { border-radius: var(--pill); }
.due-pick { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-btn); }
.due-pick:hover, [data-theme="dark"] .due-pick:hover { filter: brightness(1.1); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); margin-right: 8px; }
.dot-primary { background: var(--primary); }
.dot-warning { background: #f0a92c; }
.dot-success { background: var(--success); }

/* <span class="avatar" style="--avatar: #1156b0">AB</span> or an <img class="avatar">. */
.avatar { --size: 32px; display: inline-grid; place-items: center; flex: none; width: var(--size); height: var(--size); border-radius: 50%; background: var(--avatar, var(--surface-3)); color: var(--avatar-ink, #fff); font-size: calc(var(--size) * .38); font-weight: 800; letter-spacing: .02em; object-fit: cover; user-select: none; }
.avatar-sm { --size: 24px; }
.avatar-lg { --size: 44px; }
.avatar-xl { --size: 64px; }
.avatar-empty { background: var(--surface-3); color: var(--text-3); }
/* An avatar and a name: <span class="who"><span class="avatar avatar-sm">AB</span><span>Name</span></span> */
.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: .9375rem; font-weight: 700; color: var(--text-2); }
.who > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   7. Menus, dialogs, toasts
   ========================================================================== */
/* <div class="menu"><button data-menu-toggle aria-expanded="false" aria-controls="m1">..</button>
     <div class="menu-panel" id="m1" hidden> .menu-item ... </div></div> */
.menu { position: relative; }
.avatar-btn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; }
.avatar-btn .avatar { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px transparent; transition: box-shadow .2s; }
.avatar-btn:hover .avatar, .avatar-btn[aria-expanded="true"] .avatar { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--primary-soft); }
.avatar-btn:focus-visible { border-radius: 50%; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 14px); z-index: 60; width: min(300px, calc(100vw - 24px)); padding: 10px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: pop .2s ease-out; transform-origin: top right; }
.menu-panel-sm { width: min(260px, calc(100vw - 24px)); }
.menu-who { display: flex; gap: 12px; align-items: center; padding: 10px 10px 16px; }
.menu-name { color: var(--text); font-weight: 900; overflow-wrap: anywhere; }
.menu-email { color: var(--text-3); font-size: .875rem; overflow-wrap: anywhere; margin-bottom: 6px; }
.menu-label { padding: 12px 12px 4px; color: var(--text-3); font-size: .8125rem; font-weight: 800; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text); font-weight: 700; text-align: left; transition: background-color .2s, color .2s; }
.menu-item:hover { background: var(--surface-3); color: var(--primary-text); }
.menu-item .icon { color: var(--text-3); transition: color .2s; }
.menu-item:hover .icon { color: inherit; }
.menu-item.is-active { background: var(--primary-soft); color: var(--primary-text); }
.menu-item.is-active .icon { color: inherit; }
.menu-sep { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }

/* A native <dialog class="dialog">. On phones it is a sheet that slides up. */
.dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 28px; background: var(--surface); color: var(--text-2); box-shadow: var(--shadow-lg); overflow: auto; }
.dialog-sm { width: min(440px, calc(100vw - 24px)); }
.dialog-wide { width: min(760px, calc(100vw - 24px)); }
.dialog::backdrop { background: var(--scrim); }
.dialog[open] { animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.dialog-body { padding: 26px 26px 8px; }
.dialog-title { font-weight: 900; font-size: 1.5rem; line-height: 1.2; margin-bottom: 14px; }
.dialog-text { margin-bottom: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 26px 24px; flex-wrap: wrap; }
.dialog-actions-start { margin-right: auto; }
@media (max-width: 639px) {
  .dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 28px 28px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .dialog[open] { animation: sheet .28s ease-out; }
  @keyframes sheet { from { transform: translateY(100%); } }
}

/* <div class="toasts" id="toasts" role="status" aria-live="polite"></div>, filled by toast(). */
.toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 14px); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 12px; border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); font-weight: 700; pointer-events: auto; animation: toast-in .25s ease-out; }
.toast-icon { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--success-soft); color: var(--success); }
.toast.is-error .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast p { flex: 1; }
.toast button { flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--text-3); display: grid; place-items: center; }
.toast button:hover { background: var(--surface-3); color: var(--text); }
.toast.is-leaving { animation: toast-out .16s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
@media (min-width: 900px) { .toasts { left: auto; right: 28px; bottom: 28px; transform: none; } }

/* ==========================================================================
   8. Stats, progress, and the header card of a detail page
   ========================================================================== */
/* Count tiles: two across on phones, four from 900px. Each can be a link;
   .is-on marks the one the list below is filtered to. */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px 14px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s; }
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat.is-on { box-shadow: var(--shadow), inset 0 0 0 2px var(--primary); }
.stat:focus-visible { border-radius: var(--radius); }
.stat-value { display: grid; place-items: center; flex: none; min-width: 48px; height: 48px; padding: 0 8px; border-radius: var(--pill); background: var(--primary-soft); color: var(--primary-text); font-weight: 900; font-size: 1.375rem; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { min-width: 0; color: var(--text); font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; }
.stat-alert .stat-value { background: var(--danger-soft); color: var(--danger); }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; } .stat { padding: 16px 20px; gap: 14px; } .stat-value { min-width: 54px; height: 54px; font-size: 1.5rem; } }

/* Progress: one rounded track, one <span class="seg"> per step.
   seg-done is filled, seg-current is the lighter "you are here" part. */
.segs { display: flex; height: 10px; margin: 12px 0 10px; border-radius: var(--pill); background: var(--surface-3); overflow: hidden; }
.seg { flex: 1; }
.seg-done { background: var(--primary); }
.seg-current { background: var(--primary-mid); border-radius: 0 var(--pill) var(--pill) 0; }
/* The same idea as separate blocks: how many of a few are used. */
.meter { display: flex; gap: 6px; }
.meter > span { flex: 1; height: 12px; border-radius: var(--pill); background: var(--surface-3); }
.meter > .is-used { background: var(--primary); }

.doc-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 22px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.doc-head .label-tone { margin-bottom: 8px; }
.doc-head-main { flex: 1 1 320px; min-width: 0; }
.doc-head h1 { overflow-wrap: anywhere; }
.doc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: 8px; font-size: .9375rem; }
.doc-meta span { display: inline-flex; align-items: center; gap: 6px; }
.doc-head .segs { max-width: 440px; height: 12px; margin: 16px 0 0; }
.doc-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 1100px) { .doc-head { padding: 28px; } }

/* ==========================================================================
   9. Lists

   <ul class="rows"> of <li class="row ..."> inside a .card. Every row is a
   tinted well laid out with grid areas, so the same markup stacks on a phone
   and becomes one line with aligned columns from 900px up. The parts:

     .row-check    a round check-off button (plain .row only)
     .row-main     title and sub-lines; usually the <a> that opens the item
     .row-who      who has it (.who)
     .row-status   a .pill
     .row-due      a .due tag
     .row-actions  buttons

   Leave a part out and its column stays empty. Pick the row to suit:
     .row            check, main, who, status, due, actions
     .row-simple     main, status, actions (a name with a count and a button)
     .row-item       main, who, status, due (no buttons; the row is the link)
     .row-action     the same with buttons: on a phone they sit underneath,
                     full width, one under the other
   ========================================================================== */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row { display: grid; align-items: center; gap: 4px 10px; padding: 8px 14px 10px 6px; background: var(--surface-2); border-radius: 16px; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "check main main" ". who status" ". due actions"; }
.row-check { grid-area: check; display: grid; place-items: center; min-width: 44px; }
.row-main { grid-area: main; display: flex; flex-direction: column; min-width: 0; padding: 2px 0; border-radius: 10px; }
.row-title { color: var(--text); font-weight: 800; overflow-wrap: anywhere; }
a.row-main:hover .row-title { color: var(--primary-text); }
.row-sub { font-size: .9375rem; overflow-wrap: anywhere; }
.row-sub-strong { color: var(--text); font-weight: 700; }
.row-who { grid-area: who; }
.row-status { grid-area: status; justify-self: end; }
.row-due { grid-area: due; justify-self: start; }
.row-actions { grid-area: actions; display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row.is-off { opacity: .6; }
@media (min-width: 900px) {
  .row { padding: 6px 14px 6px 6px; grid-template-columns: auto minmax(0, 2.2fr) minmax(0, 1fr) 130px minmax(150px, auto) minmax(96px, auto); grid-template-areas: "check main who status due actions"; gap: 16px; }
  .row-status { justify-self: start; }
}

/* A name and what is under it on the left; a count and a button on the right. */
.row-simple { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "main status actions"; padding: 10px 12px 10px 16px; gap: 6px 12px; }
@media (max-width: 639px) { .row-simple { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main status" "actions actions"; } .row-simple .row-actions { justify-content: flex-start; } }
@media (min-width: 900px) {
  .row-simple { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "main status actions"; padding: 10px 12px 10px 16px; gap: 6px 12px; }
  .row-simple .row-status { justify-self: end; }
}

/* A whole item as a row. On a phone: who and when on top, then the titles,
   then its status. */
.row-item { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who due" "main main" "status status"; padding: 12px 14px; gap: 6px 10px; }
.row-item .row-due { justify-self: end; }
.row-item .row-status { justify-self: start; }
@media (min-width: 900px) {
  .row-item { grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr) 112px minmax(170px, auto); grid-template-areas: "main who status due"; padding: 10px 16px 10px 18px; gap: 16px; }
  .row-item .row-due { justify-self: start; }
}
@media (min-width: 1200px) { .row-item { grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr) 112px 220px; } }

/* The same with buttons. On a phone they go underneath, one under the other;
   on a wide screen they sit side by side at the end of the line. */
.row-action { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who due" "main main" "status status" "actions actions"; padding: 12px 14px; gap: 6px 10px; }
.row-action .row-due { justify-self: end; }
.row-action .row-status { justify-self: start; }
.row-action .row-actions { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 8px; margin-top: 6px; }
.row-action .row-actions form { display: flex; }
.row-action .row-actions .btn { width: 100%; min-height: 44px; white-space: normal; }
@media (min-width: 900px) {
  .row-action { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) 112px minmax(150px, auto) auto; grid-template-areas: "main who status due actions"; padding: 8px 12px 8px 18px; gap: 16px; }
  .row-action .row-due { justify-self: start; }
  .row-action .row-actions { flex-direction: row; align-items: center; justify-content: flex-end; margin-top: 0; }
  .row-action .row-actions .btn { width: auto; min-height: 36px; white-space: nowrap; }
}
/* With room to spare, the button column has a set width so the columns line
   up row to row. Change 340px to fit your widest pair of buttons. */
@media (min-width: 1200px) { .row-action { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) 112px 170px 340px; } }

/* The check-off circle: a <button class="check-btn"> holding a check icon.
   -done is ticked, -off cannot be ticked yet. */
.check-btn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: transparent; position: relative; }
.check-btn::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); transition: border-color .2s, background-color .2s; }
.check-btn .icon { position: relative; transition: color .2s; }
button.check-btn:hover::before, button.check-btn:focus-visible::before { border-color: var(--success); background: var(--success); }
button.check-btn:hover, button.check-btn:focus-visible { color: var(--on-success); }
button.check-btn:focus-visible { border-radius: 50%; }
.check-btn-off { color: var(--text-3); cursor: default; }
.check-btn-off::before { border-color: transparent; background: var(--surface-3); }
.check-btn-done { color: var(--on-success); cursor: default; }
.check-btn-done::before { background: var(--success); border-color: var(--success); }

/* ==========================================================================
   10. Sign-in and error pages (no nav bar: one card in the middle)
   ========================================================================== */
.login { flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 32px var(--gutter) 40px; }
.login-logo {
  width: min(330px, 78vw); aspect-ratio: var(--brand-logo-ratio, 3 / 1); background: var(--primary);
  -webkit-mask: var(--brand-logo, none) center / contain no-repeat;
  mask: var(--brand-logo, none) center / contain no-repeat;
}
[data-theme="dark"] .login-logo { background: #ffffff; }
.login-card { position: relative; width: 100%; max-width: 440px; padding: 28px 22px; background: var(--surface); border-radius: 28px; box-shadow: var(--shadow-md); }
.login-theme { position: absolute; top: 14px; right: 14px; }
.login-title { font-size: 2rem; line-height: 1.1; margin-bottom: 6px; }
.login-sub { margin-bottom: 22px; }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 26px 0 14px; color: var(--text-3); font-size: .875rem; font-weight: 800; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 2px; border-radius: 2px; background: var(--border); }
.login-form .field:last-of-type { margin-bottom: 20px; }
.login-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin-top: 16px; font-size: .9375rem; font-weight: 800; }
.login-links a { color: var(--primary-text); min-height: 32px; display: inline-flex; align-items: center; }
.login-links a:hover { text-decoration: underline; }
.login-foot { color: var(--text-3); font-size: .875rem; text-align: center; }
@media (min-width: 900px) { .login-card { padding: 40px 36px; } .login { gap: 28px; } }

.error-page { flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 24px; }
.error-page p { max-width: 46ch; }
.error-page .btn { margin-top: 16px; }
.error-code { display: grid; place-items: center; min-width: 140px; height: 140px; padding: 0 24px; border-radius: var(--pill); background: var(--primary-soft); color: var(--primary-text); font-weight: 900; font-size: 3rem; line-height: 1; margin-bottom: 8px; }

/* ==========================================================================
   Phone menu: a hamburger that turns into an X and drops the menu down.
   The script adds .is-open to .topbar and .nav-open to <body>.
   ========================================================================== */
.nav-toggle { display: grid; place-items: center; width: 44px; height: 44px; margin-left: 2px; padding: 0; border: 0; border-radius: 50%; background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-btn); }
.nav-toggle:focus-visible { border-radius: 50%; }
.nav-toggle-box { position: relative; width: 20px; height: 14px; }
.nav-line { position: absolute; left: 50%; width: 100%; height: 2.5px; border-radius: 2px; background: currentColor; transform: translateX(-50%); }
.nav-line1 { top: 0; transition: transform .5s, top .3s; }
.nav-line2 { top: 50%; transform: translate(-50%, -50%); transition: transform .5s, top .3s; }
.nav-line3 { bottom: 0; transition: bottom .3s, opacity .3s; }
.topbar.is-open .nav-line1 { top: 50%; transform: translate(-50%, -50%) rotate(225deg); }
.topbar.is-open .nav-line2 { transform: translate(-50%, -50%) rotate(-225deg); }
.topbar.is-open .nav-line3 { bottom: 100%; opacity: 0; }

/* Phones: the bar's main button (.btn-new inside .menu-new, "+ New" on a wide
   screen) becomes a round + between the light/dark switch and the hamburger. */
@media (max-width: 899px) {
  .topbar-actions .menu-new { order: 1; margin-left: 2px; }
  .topbar-actions .nav-toggle { order: 2; margin-left: 6px; }
  .btn-new { width: 44px; height: 44px; min-height: 0; padding: 0; gap: 0; justify-content: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); box-shadow: none; }
  .btn-new > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .btn-new:hover, [data-theme="dark"] .btn-new:hover { filter: none; transform: none; background: var(--primary); color: var(--on-primary); }
  .btn-new[aria-expanded="true"] { background: var(--primary); color: var(--on-primary); }
  .btn-new:focus-visible { border-radius: 50%; }
}
@media (max-width: 479px) {
  .topbar-actions .icon-btn { width: 40px; }
  .topbar-actions .menu-new { margin-left: 0; }
  .topbar-actions .nav-toggle { margin-left: 4px; }
}

.mobile-menu {
  position: absolute; top: 100%; left: 0; right: 0; z-index: -1;
  max-height: calc(100dvh - var(--topbar-h)); overflow-y: auto; overscroll-behavior: contain;
  padding: 14px var(--gutter) calc(18px + env(safe-area-inset-bottom));
  background: var(--surface); border-radius: 0 0 26px 26px; box-shadow: var(--shadow-lg);
  transform: scaleY(0); transform-origin: top; visibility: hidden;
  transition: transform .4s, visibility 0s .4s;
}
.topbar.is-open .mobile-menu { transform: scaleY(1); visibility: visible; transition: transform .4s, visibility 0s; }
.mobile-links { display: flex; flex-direction: column; gap: 6px; }
.mobile-links > li { opacity: 0; transform: translateY(-28px); transition: transform .5s, opacity .6s; }
.topbar.is-open .mobile-links > li { opacity: 1; transform: none; }
.topbar.is-open .mobile-links > li:nth-child(1) { transition-delay: .05s; }
.topbar.is-open .mobile-links > li:nth-child(2) { transition-delay: .1s; }
.topbar.is-open .mobile-links > li:nth-child(3) { transition-delay: .15s; }
.topbar.is-open .mobile-links > li:nth-child(4) { transition-delay: .2s; }
.topbar.is-open .mobile-links > li:nth-child(5) { transition-delay: .25s; }
.topbar.is-open .mobile-links > li:nth-child(6) { transition-delay: .3s; }
.topbar.is-open .mobile-links > li:nth-child(7) { transition-delay: .35s; }
.topbar.is-open .mobile-links > li:nth-child(n + 8) { transition-delay: .4s; }
.mobile-link { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 16px; border-radius: 16px; color: var(--text); font-weight: 800; font-size: 1.0625rem; transition: background-color .2s, color .2s; }
.mobile-link .icon { color: var(--text-3); }
.mobile-link:hover { background: var(--surface-2); }
.mobile-link.is-active { background: var(--primary-soft); color: var(--primary-text); }
.mobile-link.is-active .icon { color: inherit; }
.mobile-link .tab-badge { margin-left: auto; }
/* A group set apart by a line: more links under a .menu-label, or the account. */
.mobile-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.mobile-group .menu-label { display: flex; align-items: center; gap: 6px; padding-left: 16px; }
.mobile-group .menu-who { padding: 12px 6px 10px; }
.mobile-scrim { position: fixed; inset: 0; z-index: 39; background: var(--scrim); opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s; }
body.nav-open { overflow: hidden; }
body.nav-open .mobile-scrim { opacity: 1; visibility: visible; transition: opacity .3s, visibility 0s; }

/* ==========================================================================
   Motion and print
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .mobile-scrim, .toasts, .toolbar, .doc-head-actions, .site-foot { display: none !important; }
  .page { padding: 0; }
}

/* ==========================================================================
   THE SCRIPT. Copy everything between the two lines of dashes into a .js file
   (or a <script> at the end of <body>). No framework, about 90 lines.

   It looks for these attributes:
     data-theme-toggle           a button that flips light / dark
     data-theme-set="light"      a button that picks light, dark or system
     data-menu-toggle            a button that opens the panel named by its aria-controls
     data-topbar                 on .topbar
     data-nav-toggle             the hamburger
     data-nav-close              anything that closes the phone menu (the scrim)
     data-dialog="some-id"       a button that opens that <dialog>
     data-close                  a button inside a dialog that closes it
   and gives you toast('Saved.') and toast('That failed.', 'error').

   --------------------------------------------------------------------------
(function () {
  'use strict';
  const root = document.documentElement;
  const $ = (sel, el) => (el || document).querySelector(sel);
  const $$ = (sel, el) => Array.from((el || document).querySelectorAll(sel));

  // Theme: 'light', 'dark' or 'system', remembered in this browser.
  const media = window.matchMedia('(prefers-color-scheme: dark)');
  function applyTheme(pref, save) {
    const dark = pref === 'dark' || (pref === 'system' && media.matches);
    root.dataset.themePref = pref;
    root.dataset.theme = dark ? 'dark' : 'light';
    if (save) { try { localStorage.setItem('theme', pref); } catch (e) { } }
    $$('[data-theme-set]').forEach((b) => b.setAttribute('aria-checked', String(b.dataset.themeSet === pref)));
  }
  media.addEventListener('change', () => { if (root.dataset.themePref === 'system') applyTheme('system'); });
  applyTheme(root.dataset.themePref || 'system');

  // Toasts
  const svg = (body, size) => '<svg class="icon" width="' + size + '" height="' + size + '" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">' + body + '</svg>';
  const ICON = {
    check: '<path d="M20 6 9 17l-5-5"/>',
    alert: '<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>',
    x: '<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',
  };
  function toast(message, kind) {
    let box = $('#toasts');
    if (!box) {
      box = document.createElement('div');
      box.id = 'toasts'; box.className = 'toasts';
      box.setAttribute('role', 'status'); box.setAttribute('aria-live', 'polite');
      document.body.appendChild(box);
    }
    const isError = kind === 'error';
    const el = document.createElement('div');
    el.className = 'toast' + (isError ? ' is-error' : '');
    el.innerHTML = '<span class="toast-icon">' + svg(isError ? ICON.alert : ICON.check, 18) + '</span><p></p>' +
      '<button type="button" aria-label="Dismiss">' + svg(ICON.x, 16) + '</button>';
    $('p', el).textContent = message;
    const close = () => { el.classList.add('is-leaving'); setTimeout(() => el.remove(), 180); };
    $('button', el).addEventListener('click', close);
    box.appendChild(el);
    setTimeout(close, isError ? 8000 : 4500);
  }
  window.toast = toast;

  // Phone menu
  const topbar = $('[data-topbar]');
  const navToggle = $('[data-nav-toggle]');
  function setNav(open) {
    if (!topbar || !navToggle) return;
    topbar.classList.toggle('is-open', open);
    document.body.classList.toggle('nav-open', open);
    navToggle.setAttribute('aria-expanded', String(open));
    navToggle.setAttribute('aria-label', open ? 'Close menu' : 'Menu');
  }
  if (navToggle) {
    navToggle.addEventListener('click', () => setNav(!topbar.classList.contains('is-open')));
    $$('[data-nav-close]').forEach((el) => el.addEventListener('click', () => setNav(false)));
    window.matchMedia('(min-width: 900px)').addEventListener('change', (e) => { if (e.matches) setNav(false); });
  }

  // Menus and dialogs
  function closeMenus(except) {
    $$('[data-menu-toggle][aria-expanded="true"]').forEach((btn) => {
      if (btn === except) return;
      btn.setAttribute('aria-expanded', 'false');
      const panel = document.getElementById(btn.getAttribute('aria-controls'));
      if (panel) panel.hidden = true;
    });
  }
  document.addEventListener('click', (e) => {
    const t = e.target;
    const menuBtn = t.closest('[data-menu-toggle]');
    if (menuBtn) {
      const panel = document.getElementById(menuBtn.getAttribute('aria-controls'));
      const open = menuBtn.getAttribute('aria-expanded') !== 'true';
      closeMenus(menuBtn);
      setNav(false);
      menuBtn.setAttribute('aria-expanded', String(open));
      panel.hidden = !open;
      return;
    }
    if (!t.closest('.menu-panel')) closeMenus();

    if (t.closest('[data-theme-toggle]')) { applyTheme(root.dataset.theme === 'dark' ? 'light' : 'dark', true); return; }
    const themeSet = t.closest('[data-theme-set]');
    if (themeSet) { applyTheme(themeSet.dataset.themeSet, true); return; }

    const opener = t.closest('[data-dialog]');
    if (opener) { const dlg = document.getElementById(opener.dataset.dialog); if (dlg) dlg.showModal(); return; }
    if (t.closest('[data-close]')) { t.closest('dialog').close(); return; }
    if (t.tagName === 'DIALOG') {   // a click on the backdrop
      const r = t.getBoundingClientRect();
      if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) t.close();
    }
  });
  document.addEventListener('keydown', (e) => {
    if (e.key !== 'Escape') return;
    const open = $('[data-menu-toggle][aria-expanded="true"]');
    if (open) { closeMenus(); open.focus(); }
    if (topbar && topbar.classList.contains('is-open')) { setNav(false); navToggle.focus(); }
  });
})();
   --------------------------------------------------------------------------
   ========================================================================== */
