    :root {
      --bg: #f0f0f0;
      --surface: #ffffff;
      --surface-alt: #f5f5f5;
      --text: #262626;
      --muted: #757575;
      --border: #d8d8d8;
      --accent: #1c69d4;
      --focus: #0653b6;
      --silver: #bbbbbb;
      --danger: #9f4c4c;
      --success: #4f7b63;
      --shadow: 0 2px 8px rgba(0,0,0,0.08);
      --nav-bg: #1a1a1a;
      /* Solid counterpart to --nav-bg for borders/rings (a theme may set
         --nav-bg to a gradient, which is invalid as a border-color). */
      --nav-ring: var(--nav-bg);
      /* legacy aliases still referenced in templates */
      --primary: var(--accent);
      --primary-soft: rgba(28,105,212,0.15);

      /* ── Layout foundation ───────────────────────────────────────
         Width tiers each content zone can opt into via the
         `layout_class` block in base.html. Default is layout-wide,
         which reproduces the historical 1520px cap. */
      --layout-read: 820px;    /* forms, timelines, reading measure   */
      --layout-wide: 1520px;   /* default — historical cap            */
      --layout-fluid: 2100px;  /* data-dense: kanban boards, tables   */
      --gutter: 1.25rem;       /* content inset (matches old shell)   */
      --radius: 0;             /* current square aesthetic            */

      /* ── Component tokens ────────────────────────────────────────
         Intent-named and value-preserving: each token equals the
         literal it replaced, so a component rule that adopts a token
         renders identically. Reuse/extend these when building or
         refactoring components rather than hard-coding new values. */
      --pad-page: 1.2rem;            /* .page surface inset            */
      --pad-card: 1rem;              /* .card inset                    */
      --pad-btn: 0.58rem 0.9rem;     /* buttons / submit inputs        */
      --pad-input: 0.62rem 0.72rem;  /* text inputs, select, textarea  */
      --pad-cell: 0.52rem;           /* table th/td                    */
      --pad-nav-link: 0.35rem 0.62rem; /* topbar nav links             */
      --gap-grid: 1rem;              /* .grid gutter                   */
      --gap-card: 0.9rem;            /* space above a stacked card     */
      --gap-table: 0.5rem;           /* space above a table            */
      --font-h1: 2rem;               /* .page h1                       */
      --font-h2: 1.5rem;             /* .page h2                       */

      /* ── Status colour families ──────────────────────────────────
         Canonical soft-background / border / strong-text triplets for
         the four semantic states. Used by alerts, toasts and badges,
         and reused by per-app templates. Dark values live in the
         [data-theme="dark"] block below. */
      --info-soft: #ebf5ff;    --info-border: #bfdfff;    --info-text: #15538a;
      --success-soft: #e9f7ef; --success-border: #b7e3c7; --success-text: #2f7d54;
      --warn-soft: #fff8e8;    --warn-border: #f2dfb2;    --warn-text: #8b5e1a;
      --danger-soft: #fdecec;  --danger-border: #f4c5c5;  --danger-text: #9f4c4c;

      --on-accent: #ffffff;    /* text on accent/coloured buttons     */

      /* ── Bootstrap colour bridge ─────────────────────────────────
         Bootstrap's Reboot colours headings, table cells, labels and
         emphasis text from its own --bs-* variables (fixed light
         values), so those elements ignored our theme and stayed dark
         in dark mode. Bind Bootstrap's colour system to our tokens;
         because these reference --text/--muted/etc., they flip
         automatically with the dark theme. */
      --bs-body-color: var(--text);
      --bs-body-bg: var(--bg);
      --bs-heading-color: var(--text);
      --bs-emphasis-color: var(--text);
      --bs-secondary-color: var(--muted);
      --bs-tertiary-color: var(--muted);
      --bs-border-color: var(--border);
      --bs-link-color: var(--accent);
      --bs-link-hover-color: var(--focus);
    }

    /* ── Dark theme ──────────────────────────────────────────────────
       Neutral-charcoal palette. Applied when <html data-theme="dark">.
       Most of the UI flips automatically because rules reference the
       neutral tokens; only literals that couldn't be tokenised remain
       light (documented as Stage-B per-template follow-up). The topbar
       is dark in both themes, so nav tokens are intentionally NOT
       overridden here. */
    html[data-theme="dark"] {
      --bg: #14161a;
      --surface: #1e2127;
      --surface-alt: #262a31;
      --text: #e4e6ea;
      --muted: #9aa1ab;
      --border: #363a42;
      --silver: #6b7280;
      --shadow: 0 2px 10px rgba(0,0,0,0.5);
      --accent: #5b9be8;
      --focus: #7fb0ee;
      --primary: var(--accent);
      --primary-soft: rgba(91,155,232,0.22);
      --success: #6cc79a;
      --danger: #e79a9a;

      --info-soft: #12283b;    --info-border: #1d3f5c;    --info-text: #8fc0f0;
      --success-soft: #123024; --success-border: #1f4d38; --success-text: #6cc79a;
      --warn-soft: #33280f;    --warn-border: #574a24;    --warn-text: #e0b26a;
      --danger-soft: #3a1e1e;  --danger-border: #5c2f2f;  --danger-text: #e79a9a;

      /* ── CKEditor 5 (Lark theme) dark mode ───────────────────────
         CKEditor defines its colours as --ck-* custom properties in
         :root; overriding them here (higher specificity) themes every
         editor instance globally, including balloon/dropdown panels
         that CKEditor appends to <body>. Base vars cascade to derived
         ones; the rest are set explicitly. */
      --ck-color-base-background: #1e2127;   /* editable, panels, dialogs */
      --ck-color-base-foreground: #262a31;
      --ck-color-base-border: #363a42;
      --ck-color-base-text: #e4e6ea;
      --ck-color-text: #e4e6ea;

      --ck-color-toolbar-background: #262a31;
      --ck-color-toolbar-border: #363a42;

      --ck-color-button-default-hover-background: #363a42;
      --ck-color-button-default-active-background: #363a42;
      --ck-color-button-on-background: #12283b;
      --ck-color-button-on-hover-background: #17324a;
      --ck-color-button-on-color: #5b9be8;

      --ck-color-input-background: #1e2127;
      --ck-color-input-border: #363a42;
      --ck-color-input-text: #e4e6ea;
      --ck-color-input-disabled-background: #262a31;

      --ck-color-dropdown-panel-background: #1e2127;
      --ck-color-dropdown-panel-border: #363a42;
      --ck-color-panel-background: #1e2127;
      --ck-color-panel-border: #363a42;
      --ck-color-list-background: #1e2127;
      --ck-color-list-button-hover-background: #262a31;

      --ck-color-engine-placeholder-text: #9aa1ab;
      --ck-color-editable-blur-selection: #2a2e35;
      --ck-color-shadow-drop: rgba(0,0,0,.4);
      --ck-color-shadow-drop-active: rgba(0,0,0,.5);
      --ck-color-shadow-inner: rgba(0,0,0,.3);
      --ck-color-focus-border: #5b9be8;
      --ck-color-focus-outer-shadow: rgba(91,155,232,.25);
    }

    /* ── Pink theme ──────────────────────────────────────────────────
       Light-based: inherits every :root token except the accent family
       and a pink-tinted chrome. All the [data-theme="dark"] component
       overrides don't match, so the rest of the UI keeps its light look.
       CKEditor keeps its default light Lark theme (no --ck-* needed). */
    html[data-theme="pink"] {
      --bg: #fdf2f6;
      --surface: #ffffff;
      --surface-alt: #fbe9f0;
      --border: #f0cdda;
      --accent: #d6336c;
      --focus: #a61e4d;
      --primary: var(--accent);
      --primary-soft: rgba(214,51,108,0.15);
      /* Deep magenta topbar so the existing white nav text stays legible. */
      --nav-bg: #7a1e3e;
      --nav-ring: #7a1e3e;
    }

    /* ── Proud theme (pride) ─────────────────────────────────────────
       Light-based, neutral surfaces, a solid pride-purple accent for
       links/borders/active states, and a rainbow gradient reserved for
       the topbar only. --nav-ring stays solid (borders can't be a
       gradient). White nav text sits on the darker gradient stops. */
    html[data-theme="proud"] {
      --accent: #7048e8;
      --focus: #5f3dc4;
      --primary: var(--accent);
      --primary-soft: rgba(112,72,232,0.15);
      --nav-bg: linear-gradient(90deg,
        #9c1f1f 0%, #b5580f 18%, #9c7a12 36%,
        #1f7a3d 54%, #1f5aa8 72%, #5b2a8a 100%);
      --nav-ring: #5f3dc4;
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      color: var(--text);
      background: var(--bg);
      font-family: Inter, system-ui, -apple-system, Helvetica, Arial, sans-serif;
      line-height: 1.15;
      font-size: 16px;
      font-weight: 400;
    }

    a {
      color: var(--accent);
      text-decoration: none;
    }

    a:hover { text-decoration: underline; }

    /* Reboot colours headings/table-headers/labels independently of our
       token; bind them to --text so they flip in dark mode. Deliberate
       muted titles use their own class and win on specificity. */
    h1, h2, h3, h4, h5, h6,
    th, label { color: var(--text); }

    /* Full-bleed outer wrapper. Width is delegated to the tier
       classes below so chrome (topbar) can span edge-to-edge while
       content sits in a centered, capped column. */
    .site-shell {
      width: 100%;
    }

    /* Content width tiers — opt in per page via {% block layout_class %}.
       layout-wide is the default and matches the historical layout. */
    .layout {
      width: 100%;
      margin: 0 auto;
      padding: var(--gutter);
    }
    .layout-read  { max-width: var(--layout-read); }
    .layout-wide  { max-width: var(--layout-wide); }
    .layout-fluid { max-width: min(98vw, var(--layout-fluid)); }

    /* ── Topbar (dark nav) ─────────────────────────────────────── */
    .topbar {
      position: sticky;
      top: 0;
      z-index: 20;
      border: none;
      border-bottom: 1px solid rgba(255,255,255,0.08);
      background: var(--nav-bg);
      box-shadow: none;
      border-radius: 0;
      backdrop-filter: none;
      /* Full-bleed background; horizontal padding grows on very wide
         viewports so the nav content aligns with the widest (fluid)
         content column instead of stretching edge-to-edge. */
      padding: 0.7rem max(1rem, calc((100% - var(--layout-fluid)) / 2));
      display: grid;
      gap: 0.65rem;
    }

    .topbar-row {
      display: flex;
      align-items: center;
      gap: 0.75rem;
    }

    .desktop-only {}

    .mobile-only {
      display: none;
    }

    .brand {
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      font-weight: 900;
      color: #ffffff;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }

    .brand:hover { text-decoration: none; color: #ffffff; }

    .brand-logo {
      width: 144px;
      height: 42px;
      object-fit: contain;
      display: block;
    }

    .brand-mark {
      width: 28px;
      height: 28px;
      border-radius: 0;
      display: inline-grid;
      place-items: center;
      color: #fff;
      background: var(--accent);
      font-size: 0.72rem;
      font-weight: 700;
    }

    .main-nav {
      display: inline-flex;
      align-items: center;
      gap: 0.3rem;
      flex-wrap: nowrap;
      white-space: nowrap;
    }

    .global-search {
      margin: 0;
      display: flex;
      align-items: center;
      flex: 1;
      min-width: 0;
    }

    .global-search input {
      margin: 0;
      flex: 1;
      min-width: 0;
    }

    .nav-link {
      padding: var(--pad-nav-link);
      border-radius: 0;
      color: #ffffff;
      font-weight: 900;
      font-size: 0.9rem;
      transition: opacity 0.15s ease;
      letter-spacing: 0.02em;
    }

    .nav-link:hover {
      text-decoration: none;
      color: #ffffff;
      background: rgba(255,255,255,0.1);
      opacity: 1;
    }

    .nav-link.is-active {
      color: #ffffff;
      background: rgba(255,255,255,0.12);
      border: none;
      border-bottom: 2px solid #ffffff;
    }

    .lang-switch {
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      margin: 0;
    }

    .lang-switch select {
      width: auto;
      min-width: 84px;
      padding: 0.4rem 0.45rem;
      border-radius: 0;
      font-size: 0.85rem;
    }

    .menu-lang {
      margin: 0.2rem 0;
      gap: 0.45rem;
    }

    .menu-lang label {
      margin-bottom: 0;
      color: var(--muted);
      font-size: 0.82rem;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }

    .menu-lang select {
      min-width: 100%;
    }

    .user-menu,
    .notif-menu {
      position: relative;
      align-self: center;
      z-index: 31;
      flex-shrink: 0;
    }

    .user-menu[open],
    .notif-menu[open] {
      z-index: 41;
    }

    .user-menu summary,
    .notif-menu summary {
      list-style: none;
      display: inline-flex;
      align-items: center;
      gap: 0.55rem;
      cursor: pointer;
      border: 1px solid rgba(255,255,255,0.25);
      background: rgba(255,255,255,0.08);
      padding: 0.3rem 0.55rem 0.3rem 0.35rem;
      border-radius: 0;
      box-shadow: none;
      color: #ffffff;
    }

    .user-menu summary::-webkit-details-marker,
    .notif-menu summary::-webkit-details-marker { display: none; }

    /* Notifications bell trigger */
    .notif-menu summary { position: relative; padding: 0.3rem 0.5rem; }
    .notif-bell {
      width: 30px;
      height: 30px;
      display: grid;
      place-items: center;
      /* Calm "all caught up" state by default. */
      color: rgba(255,255,255,0.62);
      transition: color 0.15s ease, transform 0.15s ease;
    }
    .notif-bell svg { width: 20px; height: 20px; display: block; }
    .notif-menu summary:hover .notif-bell { color: #ffffff; }
    /* Brighter bell + a gentle nudge when something is unread. */
    .notif-menu summary.has-unread .notif-bell { color: #ffffff; }
    .notif-menu summary.has-unread .notif-bell svg { animation: bell-swing 1.6s ease-in-out 1; transform-origin: top center; }
    @keyframes bell-swing {
      0%, 70%, 100% { transform: rotate(0); }
      78% { transform: rotate(11deg); }
      86% { transform: rotate(-8deg); }
      94% { transform: rotate(4deg); }
    }
    .notif-menu .menu-badge {
      position: absolute;
      top: -4px;
      right: -4px;
      min-width: 1.1rem;
      height: 1.1rem;
      padding: 0 0.28rem;
      font-size: 0.66rem;
      border-radius: 999px;
      border: 2px solid var(--nav-ring);
      box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
    }

    .avatar {
      width: 30px;
      height: 30px;
      border-radius: 0;
      display: grid;
      place-items: center;
      background: var(--accent);
      color: #fff;
      font-weight: 700;
      font-size: 0.82rem;
      position: relative;
    }

    .avatar.has-notifications::after {
      content: "";
      position: absolute;
      top: -2px;
      right: -2px;
      width: 9px;
      height: 9px;
      border-radius: 0;
      background: #c0392b;
      border: 2px solid var(--nav-ring);
    }

    .user-caption {
      font-size: 0.87rem;
      color: rgba(255,255,255,0.8);
      font-weight: 700;
      max-width: 130px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .menu-badge {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 1.35rem;
      height: 1.35rem;
      padding: 0 0.35rem;
      border-radius: 0;
      background: #c0392b;
      color: #fff;
      font-size: 0.72rem;
      font-weight: 800;
      line-height: 1;
    }

    .menu-panel {
      position: absolute;
      right: 0;
      top: calc(100% + 0.45rem);
      width: 230px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 0;
      box-shadow: var(--shadow);
      padding: 0.55rem;
      display: grid;
      gap: 0.3rem;
    }

    .user-menu .menu-panel,
    .notif-menu .menu-panel {
      width: 340px;
    }

    .menu-item {
      display: block;
      padding: 0.5rem 0.6rem;
      border-radius: 0;
      color: var(--text);
      font-size: 0.93rem;
      font-weight: 600;
    }

    .menu-item:hover {
      background: var(--surface-alt);
      text-decoration: none;
    }

    .menu-divider {
      margin: 0.3rem 0;
      height: 1px;
      background: var(--border);
    }

    /* Small section heading inside a menu (e.g. the theme picker). */
    .menu-label {
      padding: 0.4rem 0.6rem 0.2rem;
      font-size: 0.7rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--muted);
    }

    /* Active theme option gets a trailing check. */
    .theme-option.is-active { color: var(--accent); }
    .theme-option.is-active::after {
      content: "✓";
      float: right;
      font-weight: 700;
    }

    .menu-item-danger {
      color: var(--danger);
    }

    .menu-panel form {
      margin: 0;
      display: block;
    }

    .notification-preview-section {
      display: grid;
      gap: 0.35rem;
    }

    .notification-preview-list {
      display: grid;
      gap: 0.35rem;
    }

    .notification-preview-item {
      display: grid;
      gap: 0.2rem;
      padding: 0.55rem 0.6rem;
      border-radius: 0;
      border: 1px solid var(--border);
      background: var(--surface-alt);
      color: var(--text);
      transition: background 0.15s ease, border-color 0.15s ease;
    }

    .notification-preview-item:hover {
      text-decoration: none;
      background: var(--surface-alt);
    }

    .notification-preview-item.is-unread {
      border-color: var(--info-border);
      background: var(--info-soft);
    }

    .notification-preview-item.level-warning {
      border-left: 4px solid #c48a2b;
    }

    .notification-preview-item.level-error {
      border-left: 4px solid #b34b4b;
    }

    .notification-preview-item.level-success {
      border-left: 4px solid #4f7b63;
    }

    .notification-preview-item.level-info {
      border-left: 4px solid var(--accent);
    }

    .notification-preview-meta {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.5rem;
      color: var(--muted);
      font-size: 0.77rem;
      line-height: 1.3;
    }

    .notification-preview-title {
      font-size: 0.9rem;
      font-weight: 700;
      line-height: 1.30;
    }

    .notification-preview-body {
      color: var(--muted);
      font-size: 0.84rem;
      line-height: 1.30;
    }

    .notification-preview-empty {
      margin: 0;
      padding: 0.5rem 0.6rem;
      border-radius: 0;
      background: var(--surface-alt);
      color: var(--muted);
      font-size: 0.85rem;
    }

    .status-pill {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0.18rem 0.5rem;
      border-radius: 0;
      font-size: 0.75rem;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      background: var(--info-soft);
      color: var(--info-text);
    }

    .status-pill-warning {
      background: var(--warn-soft);
      color: var(--warn-text);
    }

    .status-pill-error {
      background: var(--danger-soft);
      color: var(--danger);
    }

    .status-pill-success {
      background: var(--success-soft);
      color: var(--success);
    }

    .status-pill-info {
      background: var(--info-soft);
      color: var(--info-text);
    }

    .row-strong td {
      font-weight: 700;
    }

    .inline-details summary {
      cursor: pointer;
      color: var(--accent);
      font-size: 0.84rem;
      font-weight: 700;
    }

    .menu-panel .menu-item-button {
      appearance: none;
      width: 100%;
      text-align: left;
      border: 0;
      background: transparent;
      cursor: pointer;
      font: inherit;
      font-size: 0.93rem;
      font-weight: 600;
      box-shadow: none;
    }

    main { margin-top: 0.75rem; }

    .page {
      border-radius: 0;
      border: 1px solid var(--border);
      background: var(--surface);
      box-shadow: none;
      padding: var(--pad-page);
    }

    .page h1,
    .page h2,
    .page h3 {
      margin-top: 0;
      line-height: 1.30;
      letter-spacing: 0;
    }

    .page h1 {
      font-size: var(--font-h1);
      font-weight: 300;
      text-transform: uppercase;
      letter-spacing: 0.02em;
    }

    .page h2 {
      font-size: var(--font-h2);
      font-weight: 400;
    }

    .card {
      border: 1px solid var(--border);
      border-radius: 0;
      background: var(--surface);
      padding: var(--pad-card);
      margin-top: var(--gap-card);
    }

    /* ── Rich text content (CKEditor 5 output) ──────────────────── */
    .richtext-content {
      line-height: 1.75;
      color: var(--text);
    }

    .richtext-content > *:first-child { margin-top: 0 !important; }
    .richtext-content > *:last-child  { margin-bottom: 0 !important; }

    /* Paragraphs */
    .richtext-content p { margin: .7em 0; }

    /* Headings */
    .richtext-content h1,
    .richtext-content h2,
    .richtext-content h3,
    .richtext-content h4 {
      font-weight: 700;
      line-height: 1.3;
      margin: 1.5em 0 .5em;
      color: var(--text);
    }
    .richtext-content h1 { font-size: 1.7rem; }
    .richtext-content h2 {
      font-size: 1.3rem;
      border-bottom: 1px solid var(--border);
      padding-bottom: .3em;
    }
    .richtext-content h3 { font-size: 1.08rem; }
    .richtext-content h4 {
      font-size: .9rem;
      text-transform: uppercase;
      letter-spacing: .06em;
      color: var(--muted);
    }

    /* Links */
    .richtext-content a {
      color: var(--accent);
      text-decoration: underline;
      text-underline-offset: 2px;
    }
    .richtext-content a:hover { opacity: .8; }

    /* Lists */
    .richtext-content ul,
    .richtext-content ol {
      margin: .7em 0;
      padding-left: 1.7em;
    }
    .richtext-content ul { list-style: disc; }
    .richtext-content ol { list-style: decimal; }
    .richtext-content li { margin: .25em 0; }
    .richtext-content li > ul,
    .richtext-content li > ol { margin: .15em 0; }

    /* Todo list */
    .richtext-content ul.todo-list {
      list-style: none;
      padding-left: .25em;
    }
    .richtext-content .todo-list__label {
      display: flex;
      align-items: baseline;
      gap: .4em;
      cursor: default;
    }
    .richtext-content .todo-list__label input[type="checkbox"] {
      margin: 0;
      flex-shrink: 0;
    }

    /* Blockquote */
    .richtext-content blockquote {
      margin: 1em 0;
      padding: .6em 1em;
      border-left: 3px solid var(--accent);
      background: var(--surface-alt);
      border-radius: 0;
      color: var(--muted);
    }
    .richtext-content blockquote p { margin: 0; }

    /* Inline code */
    .richtext-content :not(pre) > code {
      font-family: "Fira Mono", "Consolas", "Monaco", "Courier New", monospace;
      font-size: .875em;
      background: var(--surface-alt);
      border: 1px solid var(--border);
      border-radius: 0;
      padding: .1em .38em;
      color: var(--text);
    }

    /* Code block — CKEditor outputs <pre><code class="language-*"> */
    .richtext-content pre {
      margin: 1em 0;
      border-radius: 0;
      overflow-x: auto;
      background: #282c34;
    }
    .richtext-content pre code {
      display: block;
      padding: 1rem 1.25rem;
      font-family: "Fira Mono", "Consolas", "Monaco", "Courier New", monospace;
      font-size: .845rem;
      line-height: 1.65;
      color: #abb2bf;
      background: transparent;
      border: none;
      border-radius: 0;
      white-space: pre;
    }

    /* Tables */
    .richtext-content figure.table {
      margin: 1em 0;
      overflow-x: auto;
    }
    .richtext-content table {
      width: 100%;
      border-collapse: collapse;
      font-size: .9rem;
    }
    .richtext-content th,
    .richtext-content td {
      border: 1px solid var(--border);
      padding: .45rem .75rem;
      text-align: left;
      vertical-align: top;
    }
    .richtext-content th {
      background: var(--surface-alt);
      font-weight: 600;
      font-size: .82rem;
    }
    .richtext-content tr:nth-child(even) td { background: var(--surface-alt); }

    /* Images */
    .richtext-content figure.image {
      margin: 1em 0;
      display: block;
    }
    .richtext-content figure.image img,
    .richtext-content img {
      max-width: 100%;
      height: auto;
      border-radius: 0;
    }
    .richtext-content figure.image.image-style-side {
      float: right;
      margin-left: 1.5em;
      max-width: 45%;
    }
    .richtext-content figcaption {
      font-size: .8em;
      color: var(--muted);
      margin-top: .35em;
      text-align: center;
    }

    /* Horizontal rule */
    .richtext-content hr {
      border: none;
      border-top: 1px solid var(--border);
      margin: 1.5em 0;
    }

    /* Alignment — CKEditor outputs style="text-align:X" */
    .richtext-content [style*="text-align:center"],
    .richtext-content .text-align-center { text-align: center; }
    .richtext-content [style*="text-align:right"],
    .richtext-content .text-align-right  { text-align: right; }
    .richtext-content [style*="text-align:justify"],
    .richtext-content .text-align-justify { text-align: justify; }

    /* Inline formatting */
    .richtext-content strong { font-weight: 700; }
    .richtext-content em     { font-style: italic; }
    .richtext-content s      { text-decoration: line-through; color: var(--muted); }

    .attachment-preview-image {
      width: 96px;
      height: 64px;
      object-fit: cover;
      border-radius: 0;
      border: 1px solid var(--border);
      display: block;
    }

    .attachment-preview-badge {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 64px;
      padding: 0.3rem 0.45rem;
      border-radius: 0;
      border: 1px solid var(--border);
      background: var(--surface-alt);
      color: var(--muted);
      font-weight: 700;
      font-size: 0.78rem;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }

    .grid { display: grid; gap: var(--gap-grid); }
    .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .muted { color: var(--muted); }

    /* ── Breadcrumbs ─────────────────────────────────────────────────────────── */
    .breadcrumbs { display:flex; align-items:center; flex-wrap:wrap; gap:.3rem .4rem; padding:0 0 .9rem; font-size:.8rem; line-height:1; }
    .breadcrumbs a { color:var(--muted); text-decoration:none; }
    .breadcrumbs a:hover { color:var(--accent); text-decoration:underline; }
    .breadcrumb-sep { color:var(--border); user-select:none; font-size:.75rem; }
    .breadcrumb-current { color:var(--text); font-weight:600; }

    .doc-link-list { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-direction: column; gap: .35rem; }
    .doc-link-list li { font-size: .88rem; }

    .alert {
      border-radius: 0;
      padding: 0.7rem 0.8rem;
      margin-bottom: 0.65rem;
      border: 1px solid;
      font-size: 0.95rem;
    }

    .alert-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
    .alert-error { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
    .alert-warning { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-text); }
    .alert-info { background: var(--info-soft); border-color: var(--info-border); color: var(--info-text); }
    .toast-stack {
      position: fixed;
      top: 1rem;
      right: 1rem;
      z-index: 9999;
      display: grid;
      gap: 0.5rem;
      width: min(360px, calc(100vw - 2rem));
    }
    .toast {
      border-radius: 0;
      padding: 0.7rem 0.8rem;
      border: 1px solid;
      box-shadow: var(--shadow);
      background: var(--info-soft);
      border-color: var(--info-border);
      color: var(--info-text);
      animation: toast-in 0.18s ease-out;
    }
    .toast-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
    .toast-error { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
    .toast-warning { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-text); }
    @keyframes toast-in {
      from { opacity: 0; transform: translateY(-6px); }
      to { opacity: 1; transform: translateY(0); }
    }

    .search-hit {
      outline: 2px solid #f5c542;
      outline-offset: -2px;
    }

    .search-hit td,
    .search-hit th {
      background: #fff4bf !important;
    }

    .search-hit td:first-child::before {
      content: "●";
      display: inline-block;
      margin-right: 0.45rem;
      padding: 0.08rem 0.25rem;
      border-radius: 0;
      background: #f5c542;
      color: #3b2f04;
      font-size: 0.68rem;
      font-weight: 800;
      letter-spacing: 0.02em;
      vertical-align: middle;
    }

    form {
      display: grid;
      gap: 0.85rem;
      margin-top: 0.6rem;
    }

    label {
      display: block;
      font-weight: 700;
      margin-bottom: 0.32rem;
      font-size: 0.92rem;
    }

    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
      width: 100%;
      border: 1px solid var(--border);
      border-radius: 0;
      padding: var(--pad-input);
      background: var(--surface);
      color: var(--text);
      font: inherit;
    }

    input:not([type="checkbox"]):not([type="radio"]):focus,
    select:focus,
    textarea:focus {
      outline: 2px solid var(--accent);
      border-color: var(--focus);
    }

    /* ── Pill controls ───────────────────────────────────────────────
       Compact filter-bar and inline-table controls. Native <select>/
       <input type=date> are kept as-is (so behaviour, htmx and
       accessibility are unchanged) — this only restyles them. Square
       corners per DESIGN.md's zero-radius mandate. */
    .pill-select,
    .pill-date {
      -webkit-appearance: none;
      appearance: none;
      width: auto;
      min-height: 1.9rem;
      height: auto;
      border: 1px solid var(--border);
      border-radius: 0;
      background-color: var(--surface-alt);
      color: var(--text);
      font-size: 0.82rem;
      font-weight: 600;
    }
    .pill-select {
      padding: 0.26rem 1.55rem 0.26rem 0.75rem;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23757575' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 0.6rem center;
    }
    .pill-date {
      padding: 0.26rem 0.75rem;
    }
    .pill-date::-webkit-calendar-picker-indicator { cursor: pointer; }
    .pill-select:hover,
    .pill-date:hover { border-color: var(--accent); }
    .pill-select:focus,
    .pill-date:focus { outline: 2px solid var(--accent); border-color: var(--focus); }

    html[data-theme="dark"] .pill-select {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa1ab' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    }
    html[data-theme="dark"] .pill-date::-webkit-calendar-picker-indicator {
      filter: invert(1) brightness(1.4);
    }

    /* Text/search input matching the pill controls (square per DESIGN.md). */
    .pill-input {
      border: 1px solid var(--border);
      border-radius: 0;
      background-color: var(--surface-alt);
      color: var(--text);
      min-height: 1.9rem;
      min-width: 12rem;
      padding: 0.26rem 0.85rem;
      font-size: 0.82rem;
      width: auto;
    }
    .pill-input:hover { border-color: var(--accent); }
    .pill-input:focus { outline: 2px solid var(--accent); border-color: var(--focus); }

    input[type="checkbox"],
    input[type="radio"] {
      appearance: auto;
      -webkit-appearance: auto;
      border: none;
      border-radius: 0 !important;
      width: auto;
      height: auto;
      padding: 0;
      margin-right: 0.45rem;
      accent-color: var(--accent);
    }

    .form-check {
      display: flex;
      align-items: center;
      gap: 0.45rem;
    }

    .form-check-input {
      width: 1rem !important;
      height: 1rem !important;
      margin-top: 0 !important;
      border-radius: 0 !important;
    }

    .form-check-label {
      display: inline;
      margin-bottom: 0;
      font-weight: 600;
    }

    ul.errorlist {
      margin: 0 0 0.25rem;
      color: var(--danger);
      font-size: 0.9rem;
      padding-left: 1rem;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      margin-top: var(--gap-table);
    }

    .table-scroll {
      width: 100%;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      margin-top: var(--gap-table);
    }

    .table-scroll > table {
      margin-top: 0;
      min-width: 100%;
    }

    th,
    td {
      border-bottom: 1px solid var(--border);
      text-align: left;
      padding: 0.42rem 0.6rem;
      vertical-align: middle;
      overflow-wrap: anywhere;
    }

    table.details-table th {
      width: 210px;
      overflow-wrap: normal;
      word-break: keep-all;
    }

    th.is-sortable {
      cursor: pointer;
      user-select: none;
      white-space: nowrap;
    }

    th.is-sortable::after {
      content: " \2195";
      color: var(--muted);
      font-size: 0.82em;
    }

    th.is-sortable[data-sort-direction="asc"]::after {
      content: " \2191";
      color: var(--text);
    }

    th.is-sortable[data-sort-direction="desc"]::after {
      content: " \2193";
      color: var(--text);
    }

    tr[data-row-link] {
      cursor: pointer;
    }

    tr[data-row-link]:hover td {
      background: var(--surface-alt);
    }

    .btn,
    button,
    input[type="submit"] {
      appearance: none;
      border: 1px solid transparent;
      border-radius: 0;
      padding: var(--pad-btn);
      font: inherit;
      font-weight: 700;
      cursor: pointer;
      background: var(--accent);
      color: #fff;
      width: fit-content;
      text-decoration: none;
      transition: opacity 0.15s ease;
      line-height: 1.15;
    }

    .btn:hover,
    button:hover,
    input[type="submit"]:hover {
      text-decoration: none;
      opacity: 0.88;
      transform: none;
      box-shadow: none;
    }

    .btn:disabled,
    button:disabled {
      opacity: 0.5;
      cursor: not-allowed;
      transform: none;
      box-shadow: none;
    }

    .btn-secondary { background: var(--muted); border-color: transparent; }
    .btn-link {
      background: transparent;
      color: var(--accent);
      padding: 0.3rem 0.2rem;
      box-shadow: none;
      border-color: transparent;
    }
    .btn-link:hover { opacity: 0.75; }
    .btn-warning { background: #a6834f; }
    .btn-danger { background: var(--danger); }
    .btn-success { background: var(--success); }
    .btn-add { background: #5f8f75; }
    .btn-edit { background: #5a76a3; }
    .btn-secret { background: #c07b45; }
    .btn-otp { background: #d4bc58; color: #3f3608; }
    .btn-attach {
      background: var(--surface-alt);
      color: var(--text);
      border: 1px solid var(--border);
    }
    .btn-attach:hover {
      background: var(--surface-alt);
      color: var(--text);
      opacity: 1;
    }
    .btn-ghost {
      background: transparent;
      color: var(--text);
      border: 1px solid var(--border);
      box-shadow: none;
    }
    .btn-ghost:hover {
      background: var(--surface-alt);
      color: var(--text);
      box-shadow: none;
      opacity: 1;
    }
    .btn-icon {
      min-width: 2.2rem;
      min-height: 2.2rem;
      padding: 0.35rem 0.5rem;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      line-height: 1;
      font-size: 1rem;
    }

    .button-row {
      display: flex;
      gap: 0.55rem;
      flex-wrap: wrap;
      align-items: center;
      justify-content: flex-start;
    }

    .tab-list {
      display: flex;
      gap: 0;
      flex-wrap: wrap;
      align-items: flex-end;
      border-bottom: 2px solid var(--border);
      margin-top: 1rem;
      padding-bottom: 0;
    }

    .tab-btn {
      appearance: none;
      border: 0;
      border-bottom: 3px solid transparent;
      border-radius: 0;
      background: transparent;
      color: var(--muted);
      box-shadow: none;
      padding: 0.5rem 0.75rem;
      font-weight: 700;
      font-size: 0.9rem;
      min-height: auto;
      letter-spacing: 0.02em;
      margin-bottom: -2px;
    }

    .tab-btn:hover {
      color: var(--text);
      background: transparent;
      box-shadow: none;
      transform: none;
      opacity: 1;
      text-decoration: none;
    }

    .tab-btn.is-active {
      color: var(--text);
      border-bottom-color: var(--accent);
    }

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

    .empty-state {
      border: 1px dashed var(--border);
      border-radius: 0;
      background: var(--surface-alt);
      padding: 1rem;
      margin-top: 0.75rem;
    }

    .empty-state h3 {
      margin: 0;
      font-size: 1rem;
    }

    .empty-state p {
      margin: 0.35rem 0 0;
      color: var(--muted);
    }

    .empty-state .button-row {
      margin-top: 0.7rem;
    }

    .mobile-header-actions {
      display: none;
      align-items: center;
      gap: 0.5rem;
    }

    .mobile-menu-toggle {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 44px;
      min-height: 44px;
      padding: 0;
      border-radius: 0;
      border: 1px solid rgba(255,255,255,0.25);
      background: rgba(255,255,255,0.08);
      color: #ffffff;
      font-size: 1.25rem;
      line-height: 1;
      box-shadow: none;
    }

    .mobile-avatar-link {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 44px;
      min-height: 44px;
      text-decoration: none;
    }

    .mobile-bell-link {
      position: relative;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 44px;
      min-height: 44px;
      text-decoration: none;
      color: rgba(255,255,255,0.62);
    }
    .mobile-bell-link.has-unread { color: #ffffff; }
    .mobile-bell-link .menu-badge {
      position: absolute;
      top: -4px;
      right: -6px;
      min-width: 1.1rem;
      height: 1.1rem;
      padding: 0 0.28rem;
      font-size: 0.66rem;
      border-radius: 999px;
      border: 2px solid var(--nav-ring);
    }

    .mobile-search-row {
      width: 100%;
    }

    .mobile-search-row .global-search {
      margin-top: 0;
    }

    .mobile-menu-panel {
      position: relative;
      z-index: 30;
      border-top: 1px solid rgba(255,255,255,0.12);
      margin-top: 0.3rem;
      padding-top: 0.85rem;
      padding-bottom: 0.85rem;
      display: grid;
      gap: 1rem;
      /* Cap to the viewport and scroll internally so a tall menu never runs
         off-screen (Sign Out stays reachable). */
      max-height: calc(100dvh - 6rem);
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }

    /* While the mobile menu is open, hide the floating FAB(s) so they can't
       overlap it (they live in the body stacking context, above the topbar). */
    html.mobile-menu-open .help-btn,
    html.mobile-menu-open #task-quick-action { display: none; }

    .mobile-menu-group {
      display: grid;
      gap: 0.5rem;
    }

    .mobile-menu-title {
      font-size: 0.8rem;
      color: rgba(255,255,255,0.5);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin: 0;
      padding: 0.1rem 0.1rem 0.2rem;
      font-weight: 700;
    }

    .mobile-menu-link,
    .mobile-menu-button {
      display: block;
      width: 100%;
      min-height: 44px;
      padding: 0.62rem 0.75rem;
      border: 1px solid rgba(255,255,255,0.12);
      border-radius: 0;
      color: #ffffff;
      background: rgba(255,255,255,0.06);
      text-align: left;
      font-weight: 600;
      text-decoration: none;
      box-shadow: none;
    }

    .mobile-menu-link.is-active {
      background: rgba(255,255,255,0.15);
      border-color: rgba(255,255,255,0.25);
      color: #ffffff;
    }

    .mobile-menu-link:hover,
    .mobile-menu-button:hover {
      background: rgba(255,255,255,0.12);
      text-decoration: none;
      transform: none;
      box-shadow: none;
      color: #ffffff;
      opacity: 1;
    }

    .mobile-menu-button {
      cursor: pointer;
    }

    .mobile-menu-lang {
      margin-top: 0;
      gap: 0.55rem;
    }

    .mobile-menu-lang label {
      margin-bottom: 0;
      color: rgba(255,255,255,0.6);
    }

    @media (max-width: 1023px) {
      .desktop-only {
        display: none !important;
      }

      .mobile-only {
        display: block;
      }

      .mobile-header-actions.mobile-only {
        display: inline-flex;
      }

      .layout {
        padding: 0.7rem;
      }

      .topbar {
        border-radius: 0;
        padding: 0.62rem 0.72rem;
      }

      .topbar-row {
        gap: 0.65rem;
      }

      .brand-logo {
        width: 130px;
        height: 38px;
      }
    }

    @media (min-width: 1024px) and (max-width: 1280px) {
      .topbar {
        gap: 0.45rem;
      }

      .topbar-row {
        gap: 0.55rem;
      }

      .main-nav {
        gap: 0.18rem;
      }

      .nav-link {
        padding: 0.3rem 0.5rem;
        font-size: 0.86rem;
      }

      .user-menu summary {
        padding: 0.25rem 0.48rem 0.25rem 0.3rem;
      }

      .user-caption {
        max-width: 96px;
        font-size: 0.82rem;
      }
    }

    @media (max-width: 760px) {
      .layout { padding: 0.45rem; }
      .topbar { padding: 0.56rem 0.62rem; border-radius: 0; }
      .page { padding: 0.75rem; border-radius: 0; }
      .global-search input { min-width: 0; font-size: 0.95rem; }
      .grid-2 { grid-template-columns: 1fr; }
      .user-caption { display: none; }
      .table-scroll > table {
        min-width: 560px;
      }
      .table-scroll > table.table-mobile-stack {
        min-width: 100%;
      }
      .table-mobile-stack thead {
        display: none;
      }
      .table-mobile-stack tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: 0;
        margin-top: 0.5rem;
        background: var(--surface);
        padding: 0.2rem 0;
      }
      .table-mobile-stack tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        border-bottom: 0;
        padding: 0.4rem 0.55rem;
      }
      .table-mobile-stack tbody td::before {
        content: attr(data-label);
        flex: 0 0 42%;
        max-width: 48%;
        font-weight: 700;
        color: var(--muted);
        overflow-wrap: normal;
      }
      .table-mobile-stack tbody td[data-label=""] {
        justify-content: flex-start;
      }
      .table-mobile-stack tbody td[data-label=""]::before {
        display: none;
      }
      .table-mobile-stack tbody td .button-row {
        width: 100%;
      }
      .table-mobile-stack tbody td .button-row .btn,
      .table-mobile-stack tbody td .button-row button {
        min-height: 2rem;
      }
      .table-mobile-stack tbody td a.btn,
      .table-mobile-stack tbody td button,
      .table-mobile-stack tbody td input[type="checkbox"] {
        flex-shrink: 0;
      }
    }

    @media (max-width: 420px) {
      .layout { padding: 0.3rem; }
      .topbar { padding: 0.5rem 0.52rem; border-radius: 0; }
      .page { padding: 0.62rem; border-radius: 0; }
      /* Keep the top row from overflowing sideways on very narrow phones. */
      .brand { min-width: 0; }
      .brand-logo { width: 104px; }
    }

    /* ── Page-load progress bar ─────────────────────────────────── */
    #nav-progress {
      position: fixed;
      top: 0;
      left: 0;
      width: 0%;
      height: 3px;
      background: var(--accent);
      z-index: 9999;
      opacity: 0;
      transition: width 0.22s ease, opacity 0.18s ease;
      pointer-events: none;
      border-radius: 0;
    }

    #nav-progress.running {
      opacity: 1;
    }

    #nav-progress::after {
      content: "";
      position: absolute;
      right: 0;
      top: -2px;
      width: 60px;
      height: 7px;
      background: radial-gradient(ellipse at right, rgba(255,255,255,0.5) 0%, transparent 70%);
      border-radius: 0;
    }

    /* ── Link / button click feedback ───────────────────────────── */
    .nav-loading {
      opacity: 0.55 !important;
      pointer-events: none !important;
      position: relative;
    }

    /* ── Custom confirm / shortcuts dialogs ──────────────────────── */
    dialog {
      border: 1px solid var(--border);
      border-radius: 0;
      box-shadow: var(--shadow);
      padding: 0;
      background: var(--surface);
      color: var(--text);
      max-width: calc(100vw - 2rem);
    }

    dialog::backdrop {
      background: rgba(20, 30, 48, 0.45);
      backdrop-filter: blur(3px);
    }

    .confirm-dialog-inner {
      padding: 1.25rem 1.4rem;
      max-width: 380px;
    }

    .confirm-dialog-msg {
      margin: 0;
      font-size: 0.97rem;
      line-height: 1.30;
    }

    .shortcuts-dialog-inner {
      padding: 1.25rem 1.4rem;
      width: 400px;
      max-width: calc(100vw - 2rem);
    }

    .shortcuts-dialog-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 0.75rem;
    }

    .shortcuts-table {
      width: 100%;
      margin-top: 0.35rem;
      border-collapse: collapse;
    }

    .shortcuts-table td {
      padding: 0.38rem 0.5rem;
      border-bottom: 1px solid var(--border);
      font-size: 0.9rem;
      vertical-align: middle;
    }

    .shortcuts-table tr:last-child td {
      border-bottom: 0;
    }

    .shortcuts-table td:first-child {
      white-space: nowrap;
      width: 1%;
      padding-right: 0.85rem;
    }

    kbd {
      display: inline-block;
      padding: 0.1rem 0.35rem;
      border: 1px solid var(--border);
      border-radius: 0;
      background: var(--surface-alt);
      font-family: inherit;
      font-size: 0.82rem;
      font-weight: 700;
      color: var(--text);
      box-shadow: 0 1px 0 var(--border);
      margin: 0 0.1rem;
    }

    .help-btn {
      position: fixed;
      bottom: 1.5rem;
      right: 1.5rem;
      width: 2.4rem;
      height: 2.4rem;
      border-radius: 0;
      background: var(--nav-bg);
      border: 1px solid rgba(255,255,255,0.2);
      box-shadow: 0 2px 8px rgba(0,0,0,0.2);
      color: #ffffff;
      font-size: 1rem;
      font-weight: 700;
      display: grid;
      place-items: center;
      cursor: pointer;
      z-index: 900;
      transition: opacity 0.15s ease;
    }

    .help-btn:hover {
      color: #ffffff;
      opacity: 0.85;
      box-shadow: 0 4px 12px rgba(0,0,0,0.3);
      transform: none;
    }

    /* Primary quick action — stacks above the "?" help button on desktop. */
    .help-btn-task {
      bottom: 4.2rem;
      background: var(--accent);
      border-color: var(--accent);
      font-size: 1.5rem;
      line-height: 1;
      text-decoration: none;
    }

    @media (max-width: 1023px) {
      /* The "?" button is desktop-only, so the task FAB sits alone at the bottom. */
      .help-btn-task {
        bottom: 1.5rem;
      }
    }

    /* ── Filter active state ─────────────────────────────────────── */
    [data-live-filter-input].filter-active {
      border-color: var(--accent);
      background: var(--info-soft);
      box-shadow: 0 0 0 2px rgba(28,105,212,0.15);
    }

    .filter-count {
      font-size: 0.8rem;
      color: var(--muted);
      font-weight: 700;
      white-space: nowrap;
      flex-shrink: 0;
    }

    /* ── Task create/edit modal dialogs ──────────────────────────────
       Shared by the app-wide FAB dialog (base.html include) and the Tasks
       page's project dialog. Previously duplicated inline in both templates. */
    .tasks-modal { width: min(640px, calc(100vw - 2rem)); max-width: 100%; border: 1px solid var(--border); box-shadow: var(--shadow); padding: 0; }
    .tasks-modal::backdrop { background: rgba(31,41,55,0.42); backdrop-filter: blur(2px); }
    .tasks-modal-card { padding: 0.9rem 1.4rem 1.4rem; max-height: calc(100vh - 4rem); overflow-y: auto; }
    /* Compact header: single line, small title + close, no subtitle. */
    .tasks-modal-header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.6rem; }
    .tasks-modal-header h3 { margin: 0; font-size: 1rem; letter-spacing: -0.01em; }
    .tasks-modal-header p { display: none; }
    .tasks-modal-header .btn-icon { margin: -0.2rem -0.35rem -0.2rem 0; }
    .tasks-modal-section { border: 1px solid var(--border); padding: 0.6rem 0.85rem 0.2rem; margin: 0.9rem 0 0; }
    .tasks-modal-section legend { padding: 0 0.4rem; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
    .tasks-modal-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.85rem; }
    .tasks-modal-field { margin-top: 0.2rem; }
    @media (max-width: 560px) { .tasks-modal-grid-2 { grid-template-columns: 1fr; } }
    .tasks-modal-loading { padding: 2rem 0; text-align: center; color: var(--muted); }
    /* Checkbox chips (tag picker inside the create modal). */
    .chip-select { display: flex; flex-wrap: wrap; gap: 0.4rem; max-height: 9.5rem; overflow-y: auto; padding: 0.2rem 0; }
    .chip-select:empty { display: none; }
    .chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.28rem 0.6rem; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 0.86rem; user-select: none; }
    .chip input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
    .chip:hover { border-color: var(--accent); }
    .chip:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
    .chip:has(input:checked)::before { content: "✓"; font-size: 0.78rem; }

    /* ── Shared list-page primitives ─────────────────────────────────
       Active-filter chips, sortable table headers, pager, and segmented
       control. Promoted out of crm/_crm_styles.html and tasks/task_list.html
       so every list page shares one implementation. Square corners per
       DESIGN.md. */
    .filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.6rem; }
    .filter-chips-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
    .filter-chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.55rem; font-size: 0.8rem;
      border: 1px solid var(--border); background: var(--surface-alt); color: var(--text); text-decoration: none; }
    .filter-chip:hover { border-color: var(--accent); }
    .filter-chip-x { font-weight: 700; color: var(--muted); line-height: 1; }
    .filter-chip:hover .filter-chip-x { color: var(--danger); }
    .filter-chip-clear { background: transparent; font-weight: 600; color: var(--accent); }

    .th-sort { white-space: nowrap; }
    .th-sort a.sort-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 0.25rem; }
    .th-sort a.sort-link:hover { color: var(--accent); }
    .th-sort a.sort-link.is-active { color: var(--accent); }
    .sort-arrow { font-size: 0.7rem; }

    .pager { display: flex; align-items: center; justify-content: center; gap: 0.8rem; margin-top: 1rem; }
    .pager-status { color: var(--muted); font-size: 0.85rem; }
    .pager .is-disabled { opacity: 0.45; pointer-events: none; }

    .seg { display: inline-flex; border: 1px solid var(--border); height: 2.2rem; background: var(--surface); }
    .seg-btn { display: inline-flex; align-items: center; background: transparent; color: var(--muted); border: 0; border-right: 1px solid var(--border); padding: 0 0.7rem; font-weight: 700; font-size: 0.85rem; min-height: 0; }
    .seg-btn:last-child { border-right: 0; }
    .seg-btn.is-active { background: var(--accent); color: #fff; }
    .seg-btn:hover { opacity: 1; background: var(--surface); }
    .seg-btn.is-active:hover { background: var(--accent); }

    /* ── Task status / priority / due badges ─────────────────────────
       Canonical definitions shared by the tasks list, task detail and
       dashboard (previously duplicated inline in each). Dark values in
       the override block below. */
    .tstatus-open        { background: #e7f0fb; color: #15538a; }
    .tstatus-in_progress { background: #fff1d9; color: #8b5e1a; }
    .tstatus-waiting     { background: #f3e8d0; color: #80591f; }
    .tstatus-resolved    { background: #ece9fb; color: #4b3fa3; }
    .tstatus-completed   { background: #e3f3ea; color: #2f7d54; }
    .tstatus-someday     { background: #ededed; color: #6b6b6b; }
    .tprio-0 { background: #f1f1f1; color: #6b6b6b; }
    .tprio-1 { background: #eef3fb; color: #3f618f; }
    .tprio-2 { background: #fff6e0; color: #8a6516; }
    .tprio-3 { background: #ffe9da; color: #aa4b1e; }
    .tprio-4 { background: #fde2e0; color: #a72a23; }
    .tdue-overdue { background: #fde2e0; color: #a72a23; }
    .tdue-today   { background: #e7f0fb; color: #15538a; }
    .tdue-week    { background: #e3f3ea; color: #2f7d54; }
    .tdue-later, .tdue-none { background: #f1f1f1; color: #6b6b6b; }
    /* Humanized per-task due labels; only overdue/today carry the colored chip. */
    .tdue-label { white-space: nowrap; }
    .tdue-label.tdue-overdue, .tdue-label.tdue-today { padding: .12rem .45rem; font-weight: 600; }

    /* ── Round check control (checklists) + "recently done" linger state ── */
    .t-complete-box {
      width: 1.05rem;
      height: 1.05rem;
      margin: 0 0.15rem 0 0;
      accent-color: #2f7d54;
      cursor: pointer;
      vertical-align: text-bottom;
    }
    html[data-theme="dark"] .t-complete-box { accent-color: #6cc79a; }
    /* A task completed in place lingers struck-through until the next load. */
    tr.t-done td a, .tcard.t-done .tcard-title a { text-decoration: line-through; }
    tr.t-done td, .tcard.t-done { opacity: 0.62; }
    .kb-col-hint { font-size: 0.8rem; padding: 0.4rem 0.2rem; }

    /* ── Checklist (task detail) + progress pill ── */
    .checklist-pill { font-size: 0.78rem; white-space: nowrap; }
    .checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
    .checklist-item { display: flex; align-items: center; gap: 0.5rem; }
    .checklist-item .checklist-text { flex: 1; }
    .checklist-item .checklist-text input[type="text"] {
      width: 100%; border: 1px solid transparent; background: transparent;
      padding: 0.25rem 0.35rem; font: inherit; color: inherit;
    }
    .checklist-item .checklist-text input[type="text"]:hover,
    .checklist-item .checklist-text input[type="text"]:focus { border-color: var(--border); background: var(--surface); }
    .checklist-item.is-done .checklist-text input[type="text"],
    .checklist-item.is-done .checklist-label { text-decoration: line-through; opacity: 0.6; }
    .checklist-actions { display: inline-flex; gap: 0.1rem; opacity: 0; transition: opacity 0.12s ease; }
    .checklist-item:hover .checklist-actions,
    .checklist-item:focus-within .checklist-actions { opacity: 1; }
    .checklist-add { margin-top: 0.5rem; }
    .checklist-add input { width: 100%; }
    .checklist-progress { font-size: 0.85rem; font-weight: 600; margin-left: 0.4rem; }

    html[data-theme="dark"] .tstatus-open        { background: #12283b; color: #8fbdf0; }
    html[data-theme="dark"] .tstatus-in_progress { background: #33280f; color: #e0b26a; }
    html[data-theme="dark"] .tstatus-waiting     { background: #302912; color: #d8b878; }
    html[data-theme="dark"] .tstatus-resolved    { background: #241f3d; color: #b3a8ee; }
    html[data-theme="dark"] .tstatus-completed   { background: #123024; color: #6cc79a; }
    html[data-theme="dark"] .tstatus-someday     { background: #2a2e35; color: #9aa1ab; }
    html[data-theme="dark"] .tprio-0 { background: #262a31; color: #9aa1ab; }
    html[data-theme="dark"] .tprio-1 { background: #1a2740; color: #93b4e6; }
    html[data-theme="dark"] .tprio-2 { background: #302912; color: #d8b878; }
    html[data-theme="dark"] .tprio-3 { background: #331f12; color: #e39a6a; }
    html[data-theme="dark"] .tprio-4 { background: #3a1e1e; color: #e79a9a; }
    html[data-theme="dark"] .tdue-overdue { background: #3a1e1e; color: #e79a9a; }
    html[data-theme="dark"] .tdue-today   { background: #12283b; color: #8fbdf0; }
    html[data-theme="dark"] .tdue-week    { background: #123024; color: #6cc79a; }
    html[data-theme="dark"] .tdue-later, html[data-theme="dark"] .tdue-none { background: #262a31; color: #9aa1ab; }

