/* ============================================================
   MODERN REDMINE THEME — application.css
   Drop-in Redmine 6 theme: dark mode, collapsible sidebar,
   Inter font, modern card layout, design tokens.

   This file is served INSTEAD of Redmine's default application.css
   when this theme is active. It first imports the Redmine defaults,
   then applies overrides.
   ============================================================ */

/* Load Redmine's default application.css first.
   Relative path: theme lives at themes/modern-redmine-theme/stylesheets/
   so ../../application.css resolves to /assets/application.css.
   CSS spec: @import rules must precede all other rules (except @charset and
   other @imports). Must stay at the top. */
@import url("/assets/application-4381d286.css");

/* Self-hosted Inter font — no external CDN dependency (GDPR-safe). */
/* cyrillic-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-400-cyrillic-ext-bdd1d2f0.woff2") format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-400-cyrillic-d15bc467.woff2") format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* latin-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-400-latin-ext-ad60622d.woff2") format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-400-latin-0555e090.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-500-cyrillic-ext-bdd1d2f0.woff2") format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-500-cyrillic-d15bc467.woff2") format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* latin-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-500-latin-ext-ad60622d.woff2") format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-500-latin-0555e090.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-600-cyrillic-ext-bdd1d2f0.woff2") format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-600-cyrillic-d15bc467.woff2") format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* latin-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-600-latin-ext-ad60622d.woff2") format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-600-latin-0555e090.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-700-cyrillic-ext-bdd1d2f0.woff2") format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-700-cyrillic-d15bc467.woff2") format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* latin-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-700-latin-ext-ad60622d.woff2") format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/themes/modern-redmine-theme/fonts/inter-700-latin-0555e090.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}


/* ============================================================
   MODERN REDMINE THEME — design tokens + layout + components
   ============================================================ */

/* ── 1. DESIGN TOKENS ───────────────────────────────────── */
:root {
  --c-primary:       #0891B2;  /* cyan-600 */
  --c-primary-hover: #0E7490;  /* cyan-700 */
  --c-primary-light: #ECFEFF;  /* cyan-50  */
  --c-primary-ring:  rgba(8,145,178,.25);
  --c-success:  #10B981;
  --c-warning:  #F59E0B;
  --c-danger:   #EF4444;
  --c-info:     #3B82F6;

  --c-bg:          #F0F4F8;
  --c-surface:     #FFFFFF;
  --c-surface-2:   #F7FAFC;
  --c-border:      #DDE3EA;
  --c-border-2:    #C4CDD6;
  --c-text:        #0F1923;
  --c-text-muted:  #5A6A7A;
  --c-text-subtle: #617282;   /* lightest text that still passes WCAG AA (4.5:1) on --c-bg */

  --c-topbar-bg:   #083344;   /* deep cyan-900 */
  --c-topbar-text: rgba(255,255,255,.88);
  --c-topbar-hover:rgba(255,255,255,.13);
  --c-header-bg:   #FFFFFF;
  --c-sidebar-bg:  #FFFFFF;
  --sidebar-w:     240px;

  --topbar-h:  44px;
  --header-h:  90px;   /* generous default: h1 row + tabs row */
  --total-top: 134px;  /* JS measures and overrides */

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-xs:   .75rem;
  --text-sm:   .875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;

  --sp-1: .25rem;  --sp-2: .5rem;   --sp-3: .75rem;
  --sp-4: 1rem;    --sp-5: 1.25rem; --sp-6: 1.5rem;  --sp-8: 2rem;

  --shadow-xs: 0 1px 2px rgb(0 0 0/.06);
  --shadow-sm: 0 1px 3px rgb(0 0 0/.1), 0 1px 2px -1px rgb(0 0 0/.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0/.1), 0 2px 4px -2px rgb(0 0 0/.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0/.1), 0 4px 6px -4px rgb(0 0 0/.1);

  --r-sm: .25rem;  --r: .5rem;  --r-md: .75rem;  --r-lg: 1rem;
  --t-fast: 150ms ease;  --t: 200ms ease;  --t-slow: 300ms ease;

  /* Status / alert text tokens (see flash messages, badges) */
  --c-badge-private-text: #991B1B;
  --c-flash-success-text: #065F46;
  --c-flash-error-text:   #991B1B;
  --c-flash-warning-text: #92400E;

  /* Focus ring — used by :focus-visible across all interactive elements */
  --c-focus-ring: rgba(8,145,178,.55);
  --c-selection:  rgba(8,145,178,.28);
  /* Priority arrow shapes (masks — only the alpha is used) and their colours */
  --rm-icon-up2:   url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7l4-4 4 4M3 12l4-4 4 4'/%3E%3C/svg%3E");
  --rm-icon-up:    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 9l4-4 4 4'/%3E%3C/svg%3E");
  --rm-icon-eq:    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 5.5h8M3 9h8'/%3E%3C/svg%3E");
  --rm-icon-down:  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
  --rm-icon-down2: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 2l4 4 4-4M3 7l4 4 4-4'/%3E%3C/svg%3E");
  --c-prio-highest: #DC2626;
  --c-prio-high:    #C2410C;
  --c-prio-low:     #2563EB;
  --c-prio-lowest:  #64748B;
  /* Tracker marker palette, cycled by tracker id (stable per tracker, arbitrary hue) */
  --c-trk-1: #0E7490; --c-trk-2: #DC2626; --c-trk-3: #047857;
  --c-trk-4: #C2410C; --c-trk-5: #2563EB; --c-trk-6: #9333EA;
  /* Syntax highlighting (Rouge) — AA (4.5:1) on --c-surface-2, the code block background */
  --c-syn-keyword:  #1D4ED8; --c-syn-type:     #7E22CE; --c-syn-function: #0E7490;
  --c-syn-string:   #047857; --c-syn-number:   #B45309; --c-syn-tag:      #B91C1C;
  --c-syn-comment:  #5A6A7A; --c-syn-highlight: rgba(245,158,11,.22);
  /* Desktop gradient bars (idea from the gitmike theme): top bar lighter at the top,
     project tab bar from the surface to a slightly darker tint */
  --c-topbar-grad-top:    #1C4353;
  --c-topbar-grad-bottom: #072B3A;
  --c-menu-grad-top:      #FFFFFF;
  --c-menu-grad-bottom:   #EEEFF0;

  /* Text on a --c-primary background (buttons, current page, badges) */
  --c-on-primary: white;

  /* Default SVG icon colour — Redmine core's link blue, kept as-is for Modern */
  --c-icon: #116699;

  /* Select chevron — an SVG data URI cannot read CSS variables, so the colour is
     baked in here (= --c-text-muted) and again in the dark block */
  --c-select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%235A6A7A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");

  /* Not a colour: where theme.js fetches every Gogh palette from for the search on
     My account. Propshaft rewrites this url() to the digested asset path. */
  --rm-gogh-palettes: url("/assets/themes/modern-redmine-theme/gogh/palettes-39944819.json");
}

/* Modern browsers (color-mix supported): derive hover/light/ring from
   --c-primary so changing the primary token propagates everywhere.
   Older browsers keep the hand-picked fallbacks above. */
@supports (color: color-mix(in srgb, red, white)) {
  :root {
    --c-primary-hover: color-mix(in srgb, var(--c-primary) 85%, black);
    --c-primary-light: color-mix(in srgb, var(--c-primary) 10%, white);
    --c-primary-ring:  color-mix(in srgb, var(--c-primary) 35%, transparent);
    --c-focus-ring:    color-mix(in srgb, var(--c-primary) 55%, transparent);
    --c-selection:     color-mix(in srgb, var(--c-primary) 30%, transparent);
    --c-topbar-grad-top:    color-mix(in srgb, var(--c-topbar-bg) 92%, white);
    --c-topbar-grad-bottom: color-mix(in srgb, var(--c-topbar-bg) 85%, black);
    --c-menu-grad-top:      var(--c-surface);
    --c-menu-grad-bottom:   color-mix(in srgb, var(--c-surface) 93%, var(--c-text));
    --c-prio-highest: color-mix(in srgb, var(--c-danger) 85%, var(--c-text));
    --c-prio-high:    color-mix(in srgb, var(--c-warning) 60%, var(--c-text));
    --c-prio-low:     color-mix(in srgb, var(--c-info) 85%, var(--c-text));
    --c-prio-lowest:  color-mix(in srgb, var(--c-info) 45%, var(--c-text-subtle));
    --c-trk-1: color-mix(in srgb, var(--c-primary) 85%, var(--c-text));
    --c-trk-2: color-mix(in srgb, var(--c-danger) 85%, var(--c-text));
    --c-trk-3: color-mix(in srgb, var(--c-success) 65%, var(--c-text));
    --c-trk-4: color-mix(in srgb, var(--c-warning) 60%, var(--c-text));
    --c-trk-5: color-mix(in srgb, var(--c-info) 85%, var(--c-text));
    --c-trk-6: color-mix(in srgb, color-mix(in srgb, var(--c-danger) 50%, var(--c-info)) 85%, var(--c-text));
    --c-syn-keyword:  color-mix(in srgb, var(--c-info) 55%, var(--c-text));
    --c-syn-type:     color-mix(in srgb, color-mix(in srgb, var(--c-danger) 50%, var(--c-info)) 70%, var(--c-text));
    --c-syn-function: color-mix(in srgb, var(--c-primary) 70%, var(--c-text));
    --c-syn-string:   color-mix(in srgb, var(--c-success) 35%, var(--c-text));
    --c-syn-number:   color-mix(in srgb, var(--c-warning) 35%, var(--c-text));
    --c-syn-tag:      color-mix(in srgb, var(--c-danger) 70%, var(--c-text));
    --c-syn-comment:  var(--c-text-subtle);
    --c-syn-highlight: color-mix(in srgb, var(--c-warning) 22%, transparent);
  }
}

/* ── 2. DARK MODE TOKENS ─────────────────────────────────── */
html.dark-mode {
  --c-primary:       #22D3EE;  /* cyan-400 — vibrant on dark */
  --c-primary-hover: #38BDF8;  /* sky-400 — hand-picked fallback */
  --c-primary-ring:  rgba(34,211,238,.22);
  --c-focus-ring:    rgba(34,211,238,.5);
  --c-selection:     rgba(34,211,238,.38);
  --c-topbar-grad-top:    #1F303D;
  --c-topbar-grad-bottom: #0A1A25;
  --c-menu-grad-top:      #2E3C49;
  --c-menu-grad-bottom:   #1E2C3A;
  --c-prio-highest: #F87171;
  --c-prio-high:    #FBBF24;
  --c-prio-low:     #60A5FA;
  --c-prio-lowest:  #94A3B8;
  --c-trk-1: #22D3EE; --c-trk-2: #F87171; --c-trk-3: #34D399;
  --c-trk-4: #FBBF24; --c-trk-5: #60A5FA; --c-trk-6: #C084FC;
  --c-syn-keyword:  #93C5FD; --c-syn-type:     #D8B4FE; --c-syn-function: #67E8F9;
  --c-syn-string:   #86EFAC; --c-syn-number:   #FCD34D; --c-syn-tag:      #FCA5A5;
  --c-syn-comment:  #7B9AB0; --c-syn-highlight: rgba(245,158,11,.2);

  --c-bg:          #161E2A;   /* lighter than before */
  --c-surface:     #1E2C3A;   /* lighter card bg     */
  --c-surface-2:   #243040;   /* slightly lighter    */
  --c-border:      #2E3F52;   /* lighter border      */
  --c-border-2:    #3A5068;
  --c-text:        #E8F0F8;   /* softer white        */
  --c-text-muted:  #8AAABF;
  --c-text-subtle: #7B9AB0;   /* AA on --c-surface-2 */
  --c-primary-light: rgba(34,211,238,.12);
  --c-topbar-bg:   #0C1E2C;   /* dark navy-cyan      */
  --c-header-bg:   #1E2C3A;
  --c-sidebar-bg:  #1A2635;

  --c-badge-private-text: #FCA5A5;
  --c-flash-success-text: #6EE7B7;
  --c-flash-error-text:   #FCA5A5;
  --c-flash-warning-text: #FCD34D;

  /* White on the bright dark-mode cyan is ~1.8:1; dark navy reads at ~10:1 */
  --c-on-primary: #0C1E2C;
  --c-select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%238AAABF' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
}

@supports (color: color-mix(in srgb, red, white)) {
  html.dark-mode {
    --c-primary-hover: color-mix(in srgb, var(--c-primary) 85%, white);
    --c-primary-light: color-mix(in srgb, var(--c-primary) 14%, transparent);
    --c-primary-ring:  color-mix(in srgb, var(--c-primary) 30%, transparent);
    --c-focus-ring:    color-mix(in srgb, var(--c-primary) 50%, transparent);
    --c-selection:     color-mix(in srgb, var(--c-primary) 38%, transparent);
    --c-topbar-grad-top:    color-mix(in srgb, var(--c-topbar-bg) 92%, white);
    --c-topbar-grad-bottom: color-mix(in srgb, var(--c-topbar-bg) 85%, black);
    --c-menu-grad-top:      color-mix(in srgb, var(--c-surface) 92%, var(--c-text));
    --c-menu-grad-bottom:   var(--c-surface);
    --c-prio-highest: color-mix(in srgb, var(--c-danger) 85%, var(--c-text));
    --c-prio-high:    color-mix(in srgb, var(--c-warning) 85%, var(--c-text));
    --c-prio-low:     color-mix(in srgb, var(--c-info) 80%, var(--c-text));
    --c-prio-lowest:  color-mix(in srgb, var(--c-info) 45%, var(--c-text-subtle));
    --c-trk-1: var(--c-primary);
    --c-trk-2: color-mix(in srgb, var(--c-danger) 85%, var(--c-text));
    --c-trk-3: color-mix(in srgb, var(--c-success) 85%, var(--c-text));
    --c-trk-4: color-mix(in srgb, var(--c-warning) 85%, var(--c-text));
    --c-trk-5: color-mix(in srgb, var(--c-info) 80%, var(--c-text));
    --c-trk-6: color-mix(in srgb, color-mix(in srgb, var(--c-danger) 50%, var(--c-info)) 80%, var(--c-text));
    --c-syn-keyword:  color-mix(in srgb, var(--c-info) 50%, var(--c-text));
    --c-syn-type:     color-mix(in srgb, color-mix(in srgb, var(--c-danger) 50%, var(--c-info)) 65%, var(--c-text));
    --c-syn-function: color-mix(in srgb, var(--c-primary) 75%, var(--c-text));
    --c-syn-string:   color-mix(in srgb, var(--c-success) 55%, var(--c-text));
    --c-syn-number:   color-mix(in srgb, var(--c-warning) 75%, var(--c-text));
    --c-syn-tag:      color-mix(in srgb, var(--c-danger) 70%, var(--c-text));
    --c-syn-comment:  var(--c-text-subtle);
    --c-syn-highlight: color-mix(in srgb, var(--c-warning) 20%, transparent);
  }
}

/* ── 2b. COLOUR SCHEMES ──────────────────────────────────── */
/* Optional palettes picked from the account menu (theme.js → initSchemePicker).
   Each scheme sets only raw --s-* inputs taken from a Gogh terminal palette
   (github.com/Gogh-Co/Gogh, MIT): background, foreground, muted text, an
   accent, the red/green/yellow/blue slots, and the text colour on the accent.
   The per-scheme blocks are generated by src/gen-schemes.py, which also
   contrast-checks each palette and nudges colours that fail WCAG AA.
   The block below derives every --c-* token from them, so a new scheme is
   one short block. Needs color-mix(); theme.js hides the picker without it.
   Must stay after the dark-mode blocks — same specificity, later wins. */
@supports (color: color-mix(in srgb, red, white)) {
  html[data-scheme] {
    --c-bg:          var(--s-bg);
    --c-text:        var(--s-fg);
    --c-text-muted:  var(--s-muted, color-mix(in srgb, var(--s-fg) 72%, var(--s-bg)));
    --c-text-subtle: var(--s-muted, color-mix(in srgb, var(--s-fg) 48%, var(--s-bg)));
    --c-border:      color-mix(in srgb, var(--s-fg) 15%, var(--s-bg));
    --c-border-2:    color-mix(in srgb, var(--s-fg) 24%, var(--s-bg));
    --c-primary:     var(--s-accent);
    --c-on-primary:  var(--s-on-accent);
    --c-success:     var(--s-green);
    --c-warning:     var(--s-yellow);
    --c-danger:      var(--s-red);
    --c-info:        var(--s-blue);
    --c-topbar-bg:   var(--s-topbar);
    --c-icon:        var(--c-primary);
  }
  /* Default topbar; zero specificity so a scheme's own --s-topbar wins */
  :where(html[data-scheme].dark-mode)        { --s-topbar: color-mix(in srgb, var(--s-bg) 72%, black); }
  :where(html[data-scheme]:not(.dark-mode))  { --s-topbar: color-mix(in srgb, var(--s-fg) 80%, black); }

  /* Dark schemes: cards lift towards the foreground */
  html[data-scheme].dark-mode {
    --c-surface:     color-mix(in srgb, var(--s-fg) 6%, var(--s-bg));
    --c-surface-2:   color-mix(in srgb, var(--s-fg) 10%, var(--s-bg));
    --c-sidebar-bg:  color-mix(in srgb, var(--s-fg) 3%, var(--s-bg));
    --c-header-bg:   var(--c-surface);
    --c-badge-private-text: var(--s-red);
    --c-flash-success-text: var(--s-green);
    --c-flash-error-text:   var(--s-red);
    --c-flash-warning-text: var(--s-yellow);
  }
  /* Light schemes: cards lift towards white */
  html[data-scheme]:not(.dark-mode) {
    --c-surface:     color-mix(in srgb, white 65%, var(--s-bg));
    --c-surface-2:   color-mix(in srgb, white 35%, var(--s-bg));
    --c-sidebar-bg:  var(--c-surface);
    --c-header-bg:   var(--c-surface);
    --c-badge-private-text: color-mix(in srgb, var(--s-red) 75%, black);
    --c-flash-success-text: color-mix(in srgb, var(--s-green) 70%, black);
    --c-flash-error-text:   color-mix(in srgb, var(--s-red) 75%, black);
    --c-flash-warning-text: color-mix(in srgb, var(--s-yellow) 65%, black);
  }

  /* @schemes:begin — generated by src/gen-schemes.py, do not edit */
  /* Gogh: Ayu Dark */
  html[data-scheme="ayu-dark"] {
    --s-bg: #0A0E14;  --s-fg: #B3B1AD;  --s-muted: #878785;
    --s-accent: #59C2FF;  --s-on-accent: #0A0E14;
    --s-red: #FF3333;  --s-green: #C2D94C;  --s-yellow: #FF8F40;  --s-blue: #59C2FF;
  }
  /* Gogh: Ayu Mirage */
  html[data-scheme="ayu-mirage"] {
    --s-bg: #1F2430;  --s-fg: #CCCAC2;  --s-muted: #9F9F9C;
    --s-accent: #6DCBFA;  --s-on-accent: #1F2430;
    --s-red: #ED8274;  --s-green: #87D96C;  --s-yellow: #FACC6E;  --s-blue: #6DCBFA;
  }
  /* Gogh: Catppuccin Macchiato */
  html[data-scheme="catppuccin-macchiato"] {
    --s-bg: #24273A;  --s-fg: #CAD3F5;  --s-muted: #9CA3C1;
    --s-accent: #8AADF4;  --s-on-accent: #24273A;
    --s-red: #ED8796;  --s-green: #A6DA95;  --s-yellow: #EED49F;  --s-blue: #8AADF4;
  }
  /* Gogh: Catppuccin Mocha */
  html[data-scheme="catppuccin-mocha"] {
    --s-bg: #1E1E2E;  --s-fg: #CDD6F4;  --s-muted: #9CA2BD;
    --s-accent: #89B4FA;  --s-on-accent: #1E1E2E;
    --s-red: #F38BA8;  --s-green: #A6E3A1;  --s-yellow: #F9E2AF;  --s-blue: #89B4FA;
  }
  /* Gogh: Dracula */
  html[data-scheme="dracula"] {
    --s-bg: #282A36;  --s-fg: #F8F8F2;  --s-muted: #BEBEBD;
    --s-accent: #C098F9;  --s-on-accent: #282A36;
    --s-red: #FF8888;  --s-green: #50FA7B;  --s-yellow: #F1FA8C;  --s-blue: #BD93F9;
  }
  /* Gogh: Everforest Dark */
  html[data-scheme="everforest-dark"] {
    --s-bg: #2D353B;  --s-fg: #E5DDCC;  --s-muted: #B9B5A9;
    --s-accent: #85BEB7;  --s-on-accent: #2D353B;
    --s-red: #EC9EA0;  --s-green: #A7C080;  --s-yellow: #DBBC7F;  --s-blue: #7FBBB3;
  }
  /* Gogh: GitHub Dark */
  html[data-scheme="github-dark"] {
    --s-bg: #101216;  --s-fg: #A8AFB6;  --s-muted: #848990;
    --s-accent: #6CA4F8;  --s-on-accent: #101216;
    --s-red: #F78166;  --s-green: #56D364;  --s-yellow: #E3B341;  --s-blue: #6CA4F8;
  }
  /* Gogh: GitHub Dark Dimmed */
  html[data-scheme="github-dark-dimmed"] {
    --s-bg: #22272E;  --s-fg: #BDC8D2;  --s-muted: #98A1AB;
    --s-accent: #64A5F6;  --s-on-accent: #22272E;
    --s-red: #F57E76;  --s-green: #57AB5A;  --s-yellow: #C69026;  --s-blue: #539BF5;
  }
  /* Gogh: Gruvbox Dark */
  html[data-scheme="gruvbox-dark"] {
    --s-bg: #282828;  --s-fg: #EBDBB2;  --s-muted: #B4A98B;
    --s-accent: #D79921;  --s-on-accent: #282828;
    --s-red: #E6928E;  --s-green: #98971A;  --s-yellow: #D79921;  --s-blue: #458588;
  }
  /* Gogh: Kanagawa Wave */
  html[data-scheme="kanagawa-wave"] {
    --s-bg: #1F1F28;  --s-fg: #DCD7BA;  --s-muted: #A7A391;
    --s-accent: #7E9CD8;  --s-on-accent: #1F1F28;
    --s-red: #D88385;  --s-green: #76946A;  --s-yellow: #C0A36E;  --s-blue: #7E9CD8;
  }
  /* Gogh: Material Ocean */
  html[data-scheme="material-ocean"] {
    --s-bg: #0F111A;  --s-fg: #ABAEB9;  --s-muted: #868893;
    --s-accent: #82AAFF;  --s-on-accent: #0F111A;
    --s-red: #FF5370;  --s-green: #C3E88D;  --s-yellow: #FFCB6B;  --s-blue: #82AAFF;
  }
  /* Gogh: Monokai Pro */
  html[data-scheme="monokai-pro"] {
    --s-bg: #2D2A2E;  --s-fg: #FCFCFA;  --s-muted: #C2C1C1;
    --s-accent: #FC9867;  --s-on-accent: #2D2A2E;
    --s-red: #FF88A6;  --s-green: #A9DC76;  --s-yellow: #FFD866;  --s-blue: #FC9867;
  }
  /* Gogh: Nord */
  html[data-scheme="nord"] {
    --s-bg: #2E3440;  --s-fg: #D8DEE9;  --s-muted: #ACB2BD;
    --s-accent: #88C0D0;  --s-on-accent: #2E3440;
    --s-red: #DCA8AD;  --s-green: #A3BE8C;  --s-yellow: #EBCB8B;  --s-blue: #81A1C1;
  }
  /* Gogh: One Dark Pro */
  html[data-scheme="one-dark"] {
    --s-bg: #282C34;  --s-fg: #CDD1D9;  --s-muted: #A5A9B1;
    --s-accent: #61AFEF;  --s-on-accent: #282C34;
    --s-red: #E89198;  --s-green: #98C379;  --s-yellow: #D19A66;  --s-blue: #61AFEF;
  }
  /* Gogh: Rose Pine */
  html[data-scheme="ros-pine"] {
    --s-bg: #191724;  --s-fg: #E0DEF4;  --s-muted: #A8A6BA;
    --s-accent: #C4A7E7;  --s-on-accent: #191724;
    --s-red: #EB6F92;  --s-green: #31748F;  --s-yellow: #F6C177;  --s-blue: #9CCFD8;
  }
  /* Gogh: Rose Pine Moon */
  html[data-scheme="ros-pine-moon"] {
    --s-bg: #232136;  --s-fg: #E0DEF4;  --s-muted: #ABA9BF;
    --s-accent: #C4A7E7;  --s-on-accent: #232136;
    --s-red: #ED7D9D;  --s-green: #3E8FB0;  --s-yellow: #F6C177;  --s-blue: #9CCFD8;
  }
  /* Gogh: TokyoNight */
  html[data-scheme="tokyo-night"] {
    --s-bg: #1A1B26;  --s-fg: #C0CAF5;  --s-muted: #9299BB;
    --s-accent: #7AA2F7;  --s-on-accent: #1A1B26;
    --s-red: #F7768E;  --s-green: #9ECE6A;  --s-yellow: #E0AF68;  --s-blue: #7AA2F7;
  }
  /* Gogh: Ayu Light */
  html[data-scheme="ayu-light"] {
    --s-bg: #F8F9FA;  --s-fg: #4E5257;  --s-muted: #6D7074;
    --s-accent: #2573A9;  --s-on-accent: #FFFFFF;
    --s-red: #B05152;  --s-green: #6CBF43;  --s-yellow: #ECA944;  --s-blue: #3199E1;
  }
  /* Gogh: Catppuccin Latte */
  html[data-scheme="catppuccin-latte"] {
    --s-bg: #EFF1F5;  --s-fg: #4C4F69;  --s-muted: #696C82;
    --s-accent: #1C61E9;  --s-on-accent: #FFFFFF;
    --s-red: #D20F39;  --s-green: #40A02B;  --s-yellow: #DF8E1D;  --s-blue: #1E66F5;
  }
  /* Gogh: Everforest Light */
  html[data-scheme="everforest-light"] {
    --s-bg: #FDF6E3;  --s-fg: #4A555B;  --s-muted: #6A7274;
    --s-accent: #2E769E;  --s-on-accent: #FFFFFF;
    --s-red: #C64442;  --s-green: #8DA101;  --s-yellow: #DFA000;  --s-blue: #3A94C5;
  }
  /* Gogh: GitHub Light Default */
  html[data-scheme="github-light"] {
    --s-bg: #FFFFFF;  --s-fg: #1F2328;  --s-muted: #5E6164;
    --s-accent: #0969DA;  --s-on-accent: #FFFFFF;
    --s-red: #CF222E;  --s-green: #116329;  --s-yellow: #4D2D00;  --s-blue: #0969DA;
  }
  /* Gogh: Gruvbox Light */
  html[data-scheme="gruvbox-light"] {
    --s-bg: #FBF1C7;  --s-fg: #3C3836;  --s-muted: #716C5F;
    --s-accent: #3B7174;  --s-on-accent: #FFFFFF;
    --s-red: #CC241D;  --s-green: #98971A;  --s-yellow: #D79921;  --s-blue: #458588;
  }
  /* Gogh: Kanagawa Lotus */
  html[data-scheme="kanagawa-lotus"] {
    --s-bg: #F2ECBC;  --s-fg: #4C4C5A;  --s-muted: #6A686C;
    --s-accent: #4D699B;  --s-on-accent: #FFFFFF;
    --s-red: #B43A4B;  --s-green: #6F894E;  --s-yellow: #77713F;  --s-blue: #4D699B;
  }
  /* Gogh: One Light */
  html[data-scheme="one-light"] {
    --s-bg: #F8F8F8;  --s-fg: #2A2B32;  --s-muted: #646469;
    --s-accent: #315EEE;  --s-on-accent: #FFFFFF;
    --s-red: #CF3B36;  --s-green: #41933E;  --s-yellow: #855504;  --s-blue: #315EEE;
  }
  /* Gogh: Rose Pine Dawn */
  html[data-scheme="ros-pine-dawn"] {
    --s-bg: #FAF4ED;  --s-fg: #534E73;  --s-muted: #716C89;
    --s-accent: #7A6890;  --s-on-accent: #FFFFFF;
    --s-red: #A2596E;  --s-green: #286983;  --s-yellow: #EA9D34;  --s-blue: #56949F;
  }
  /* Gogh: Solarized Light */
  html[data-scheme="solarized-light"] {
    --s-bg: #FCF4DC;  --s-fg: #42535A;  --s-muted: #647071;
    --s-accent: #1F70BD;  --s-on-accent: #FFFFFF;
    --s-red: #D11C24;  --s-green: #738A05;  --s-yellow: #A57706;  --s-blue: #2176C7;
  }
  /* Gogh: TokyoNight Day */
  html[data-scheme="tokyo-night-day"] {
    --s-bg: #E1E2E7;  --s-fg: #264386;  --s-muted: #4C6399;
    --s-accent: #225EAF;  --s-on-accent: #FFFFFF;
    --s-red: #B8204C;  --s-green: #587539;  --s-yellow: #8C6C3E;  --s-blue: #2E7DE9;
  }
  /* @schemes:end */
}

/* ── 3. BASE ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  font-family: var(--font-sans) !important;
  font-size: var(--text-sm) !important;
  background: var(--c-bg) !important;
  color: var(--c-text) !important;
  line-height: 1.6 !important;
  -webkit-font-smoothing: antialiased;
}

/* Selected text and the text cursor. Left to the browser, the selection is its own
   (or, in Vivaldi, the browser theme's) colour: in dark mode a grey-blue that barely
   shows on the dark fields. A tint of the accent follows every mode and scheme. */
::selection { background: var(--c-selection) !important; color: var(--c-text) !important; }
input, textarea, [contenteditable="true"] { caret-color: var(--c-primary); }

/* ── 3b. FOCUS VISIBLE — keyboard-only ring on all interactive elements.
   Uses :focus-visible so mouse clicks don't show the ring; keyboard
   navigation (tab) does. WCAG AA contrast met by --c-focus-ring. */
:focus { outline: none !important; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--c-primary) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 4px var(--c-focus-ring) !important;
  border-radius: var(--r-sm);
}
/* Icons + text links get a softer ring (no outline offset) */
a:focus-visible,
#top-menu a:focus-visible,
#main-menu a:focus-visible,
#sidebar a:focus-visible {
  outline-offset: 1px !important;
}

/* ── 4. TOPBAR (#top-menu) ──────────────────────────────── */
#top-menu {
  position: fixed !important;
  top: 0 !important; left: 0 !important; right: 0 !important;
  height: var(--topbar-h) !important;
  background: var(--c-topbar-bg) !important;
  color: var(--c-topbar-text) !important;
  display: flex !important;
  align-items: center !important;
  padding: 0 var(--sp-4) !important;
  z-index: 1000 !important;
  box-shadow: 0 1px 3px rgb(0 0 0/.4) !important;
  gap: 0 !important;
  overflow: hidden !important;
}

/* DOM order: #account → #loggedas → ul(nav)
   We want:   ul(nav) LEFT → loggedas RIGHT → #account FAR RIGHT
   Use order + margin tricks                                      */
#top-menu > ul {
  order: 0 !important;
  display: flex !important;
  align-items: center !important;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  gap: 2px !important;
  flex: 1 !important; /* take available space, pushes account to far right */
}

#top-menu #account {
  order: 3 !important;
  display: flex !important;
  align-items: center !important;
  margin-left: var(--sp-2) !important;
  padding-left: var(--sp-3) !important;
  border-left: 1px solid rgba(255,255,255,.15) !important;
  flex-shrink: 0 !important;
}

#top-menu #loggedas {
  order: 2 !important;
  color: var(--c-topbar-text) !important;
  font-size: var(--text-xs) !important;
  white-space: nowrap !important;
  opacity: .65 !important;
  padding: 0 var(--sp-3) !important;
  flex-shrink: 0 !important;
  border-left: 1px solid rgba(255,255,255,.12) !important;
  margin-left: auto !important; /* push loggedas+account to far right */
}

#top-menu #loggedas a { color: white !important; font-weight: 500 !important; }

#top-menu ul li a,
#top-menu ul li span.disabled {
  display: inline-flex !important;
  align-items: center !important;
  padding: var(--sp-2) var(--sp-3) !important;
  color: var(--c-topbar-text) !important;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  border-radius: var(--r-sm) !important;
  text-decoration: none !important;
  transition: background var(--t-fast) !important;
  white-space: nowrap !important;
}

#top-menu ul li a:hover { background: var(--c-topbar-hover) !important; color: white !important; }
#top-menu ul li.selected a,
#top-menu ul li a.active { background: var(--c-topbar-hover) !important; color: white !important; }

/* ── Hide mobile hamburger — not needed on desktop ───────── */
.mobile-toggle-button { display: none !important; }

/* ── ACCOUNT DROPDOWN (JS-injected) ───────────────────────
   Trigger button with avatar + name + caret; panel opens on click. */
.rm-account-dropdown {
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
}
.rm-account-trigger {
  display: inline-flex !important;
  align-items: center !important;
  gap: var(--sp-2) !important;
  background: transparent !important;
  border: none !important;
  color: var(--c-topbar-text) !important;
  padding: 4px 8px !important;
  border-radius: var(--r) !important;
  cursor: pointer !important;
  font-size: var(--text-sm) !important;
  font-family: var(--font-sans) !important;
  transition: background var(--t-fast) !important;
}
.rm-account-trigger:hover { background: var(--c-topbar-hover) !important; color: white !important; }
.rm-account-trigger[aria-expanded="true"] { background: var(--c-topbar-hover) !important; color: white !important; }
.rm-account-trigger .rm-account-caret { display: inline-flex !important; transition: transform var(--t-fast) !important; opacity: .7; }
.rm-account-trigger[aria-expanded="true"] .rm-account-caret { transform: rotate(180deg) !important; }

.rm-account-avatar {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 26px !important;
  height: 26px !important;
  border-radius: 50% !important;
  background: var(--c-primary) !important;
  color: var(--c-on-primary) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: .03em !important;
  line-height: 1 !important;
  flex-shrink: 0 !important;
}
.rm-account-avatar-lg { width: 40px !important; height: 40px !important; font-size: 14px !important; }

.rm-account-name {
  font-weight: 500 !important;
  max-width: 160px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.rm-account-panel {
  /* Fixed so the dropdown escapes #top-menu's overflow:hidden clip.
     Position is set in JS to track the trigger's bounding rect. */
  position: fixed !important;
  top: calc(var(--topbar-h) + 4px) !important;
  right: var(--sp-4) !important;
  min-width: 220px !important;
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: var(--sp-1) !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translateY(-4px) !important;
  transition: opacity var(--t-fast), transform var(--t-fast), visibility var(--t-fast) !important;
  z-index: 1001 !important;
  color: var(--c-text) !important;
}
.rm-account-panel.is-open {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
}

.rm-account-panel-head {
  display: flex !important;
  align-items: center !important;
  gap: var(--sp-3) !important;
  padding: var(--sp-3) !important;
  border-radius: var(--r-sm) !important;
  color: var(--c-text) !important;
  text-decoration: none !important;
  transition: background var(--t-fast) !important;
}
.rm-account-panel-head:hover { background: var(--c-primary-light) !important; }
.rm-account-panel-name { display: block !important; font-weight: 600 !important; color: var(--c-text) !important; }
.rm-account-panel-view { display: block !important; font-size: var(--text-xs) !important; color: var(--c-text-muted) !important; margin-top: 2px !important; }
.rm-account-panel-sep { height: 1px !important; background: var(--c-border) !important; margin: var(--sp-1) 0 !important; }

.rm-account-panel ul {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}
.rm-account-panel ul li a {
  display: flex !important;
  align-items: center !important;
  padding: var(--sp-2) var(--sp-3) !important;
  color: var(--c-text) !important;
  font-size: var(--text-sm) !important;
  text-decoration: none !important;
  border-radius: var(--r-sm) !important;
  transition: background var(--t-fast) !important;
}
.rm-account-panel ul li a:hover { background: var(--c-primary-light) !important; color: var(--c-primary) !important; }

/* Colour scheme picker (theme.js → initSchemePicker / initSchemeSettings).
   Account menu: the four most recently used schemes as dots + a link to My account.
   My account: every scheme as a small preview card, grouped dark / light. */
.rm-scheme-label {
  padding: var(--sp-1) var(--sp-3) !important;
  font-size: var(--text-xs) !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: .05em !important;
  color: var(--c-text-subtle) !important;
}
.rm-scheme-recent { display: flex !important; gap: var(--sp-2) !important; padding: var(--sp-1) var(--sp-3) var(--sp-2) !important; }
.rm-scheme-dot {
  width: 28px !important;
  height: 28px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  border: 1px solid var(--c-border-2) !important;
  cursor: pointer !important;
  transition: transform var(--t-fast), box-shadow var(--t-fast) !important;
}
.rm-scheme-dot:hover { transform: scale(1.1) !important; }
.rm-scheme-dot[aria-checked="true"] { box-shadow: 0 0 0 2px var(--c-surface), 0 0 0 4px var(--c-primary) !important; }
.rm-account-panel a.rm-scheme-more {
  display: block !important;
  padding: var(--sp-2) var(--sp-3) !important;
  font-size: var(--text-sm) !important;
  color: var(--c-text) !important;
  border-radius: var(--r-sm) !important;
  text-decoration: none !important;
}
.rm-account-panel a.rm-scheme-more:hover { background: var(--c-primary-light) !important; color: var(--c-primary) !important; }

/* My account → Sidebar position (theme.js → initSidebarSettings) */
#rm-layout .rm-side-options { display: flex !important; gap: var(--sp-2) !important; }
.rm-side-option {
  height: auto !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  width: 118px !important;
  padding: 6px !important;
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r) !important;
  color: var(--c-text) !important;
  font: inherit !important;
  font-size: var(--text-xs) !important;
  text-align: left !important;
  cursor: pointer !important;
}
.rm-side-option:hover { border-color: var(--c-primary) !important; }
.rm-side-option[aria-checked="true"] { border-color: var(--c-primary) !important; box-shadow: 0 0 0 2px var(--c-primary-ring) !important; font-weight: 600 !important; }
/* mini layout preview: <i> = sidebar, <b> = content */
.rm-side-preview { display: flex !important; gap: 4px !important; height: 46px !important; padding: 5px !important; border-radius: var(--r-sm) !important; background: var(--c-bg) !important; }
.rm-side-preview.rm-side-right { flex-direction: row-reverse !important; }
.rm-side-preview i { display: block !important; width: 28% !important; border-radius: 3px !important; background: var(--c-border-2) !important; }
.rm-side-preview b { display: block !important; flex: 1 !important; border-radius: 3px !important; background: var(--c-surface-2) !important; border: 1px solid var(--c-border) !important; }
#rm-layout .rm-scheme-hint { margin: var(--sp-2) 0 0 !important; font-size: var(--text-xs) !important; color: var(--c-text-muted) !important; }

#rm-schemes .rm-scheme-group { margin: var(--sp-2) 0 var(--sp-1) !important; font-size: var(--text-xs) !important; font-weight: 600 !important; text-transform: uppercase !important; letter-spacing: .05em !important; color: var(--c-text-subtle) !important; }
#rm-schemes .rm-scheme-grid { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)) !important; gap: var(--sp-2) !important; }
#rm-schemes .rm-scheme-hint { margin: var(--sp-3) 0 0 !important; font-size: var(--text-xs) !important; color: var(--c-text-muted) !important; }
#rm-schemes .rm-gogh { margin-top: var(--sp-4) !important; padding-top: var(--sp-3) !important; border-top: 1px solid var(--c-border) !important; }
#rm-schemes .rm-gogh-search { width: 100% !important; max-width: 420px !important; height: 32px !important; }
#rm-schemes .rm-gogh-status { margin: var(--sp-1) 0 var(--sp-2) !important; }
#rm-schemes .rm-gogh-current:not([hidden]) { margin-bottom: var(--sp-3) !important; }
#rm-schemes .rm-gogh-title { font-weight: 600 !important; color: var(--c-text) !important; }
#rm-schemes .rm-gogh-accents { padding: var(--sp-1) 0 0 !important; }
#rm-schemes .rm-gogh-note { margin-top: var(--sp-1) !important; }
.rm-scheme-card {
  /* a <button>: core's `input, select, button { height: 24px; margin: 1px 0 }` would clip it */
  height: auto !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  padding: 6px !important;
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r) !important;
  color: var(--c-text) !important;
  font: inherit !important;
  font-size: var(--text-xs) !important;
  text-align: left !important;
  cursor: pointer !important;
  transition: border-color var(--t-fast) !important;
}
.rm-scheme-card:hover { border-color: var(--c-primary) !important; }
.rm-scheme-card[aria-checked="true"] { border-color: var(--c-primary) !important; box-shadow: 0 0 0 2px var(--c-primary-ring) !important; font-weight: 600 !important; }
/* Mini preview: the scheme's own colours are set inline (--p-bg / --p-fg / --p-accent) */
.rm-scheme-preview {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  height: 46px !important;
  padding: 7px 8px !important;
  border-radius: var(--r-sm) !important;
  background: var(--p-bg) !important;
}
.rm-scheme-preview i { display: block !important; height: 5px !important; border-radius: 3px !important; background: var(--p-fg) !important; opacity: .85 !important; }
.rm-scheme-preview i:nth-child(1) { width: 70% !important; }
.rm-scheme-preview i:nth-child(2) { width: 45% !important; opacity: .5 !important; }
.rm-scheme-preview i:nth-child(3) { width: 30% !important; height: 9px !important; background: var(--p-accent) !important; opacity: 1 !important; margin-top: auto !important; }

/* Dark-mode adjustments for the panel */
html.dark-mode .rm-account-panel { background: var(--c-surface) !important; border-color: var(--c-border) !important; }
html.dark-mode .rm-account-panel ul li a:hover { background: var(--c-primary-light) !important; color: var(--c-primary) !important; }

/* ── 5. HEADER ──────────────────────────────────────────── */
#header {
  position: fixed !important;
  top: var(--topbar-h) !important;
  left: 0 !important; right: 0 !important;
  background: var(--c-header-bg) !important;
  z-index: 999 !important;
  border-bottom: 1px solid var(--c-border) !important;
  box-shadow: var(--shadow-xs) !important;
  /* padding-bottom: reserves space for #main-menu (absolute, bottom:0) + visual
     breathing room between project title and tabs. */
  padding: var(--sp-2) var(--sp-6) 58px var(--sp-6) !important;
  transition: background var(--t) !important;
  /* position:fixed already creates a containing block for absolute children like #main-menu */
}

/* When there are no project tabs, remove the extra bottom padding */
#header:not(:has(#main-menu ul li)) {
  padding-bottom: var(--sp-2) !important;
}

/* Default h1 (non-project pages: My page, Projects list, Admin, etc.) */
#header h1 {
  font-size: var(--text-lg) !important;
  font-weight: 700 !important;
  color: var(--c-text) !important;
  margin: 0 340px 0 0 !important;
  padding: var(--sp-2) 0 !important;
  line-height: 1.3 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}
#header h1 a { color: inherit !important; text-decoration: none !important; }

/* Project pages — h1 contains .breadcrumbs + .current-project. Render as a
   two-column grid: [badge] [breadcrumb ↑ / project-name ↓]. */
#header h1:has(.current-project) {
  display: grid !important;
  grid-template-columns: auto 1fr !important;
  grid-template-rows: auto auto !important;
  grid-auto-flow: column !important;
  column-gap: 10px !important;
  row-gap: 0 !important;
  align-items: center !important;
  padding: 2px 0 !important;
  font-size: 0 !important;
  line-height: 1.15 !important;
  white-space: nowrap !important;
  overflow: visible !important;
}

#header h1 > .rm-project-badge {
  grid-row: 1 / 3 !important;
  grid-column: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 34px !important;
  height: 34px !important;
  background: var(--c-primary) !important;
  color: var(--c-on-primary) !important;
  border-radius: var(--r-md) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  letter-spacing: .03em !important;
  line-height: 1 !important;
  flex-shrink: 0 !important;
  align-self: center !important;
}

#header h1 > .breadcrumbs {
  grid-row: 1 !important;
  grid-column: 2 !important;
  font-size: 10px !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: .08em !important;
  color: var(--c-text-subtle) !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

#header h1 > .breadcrumbs a.root {
  color: var(--c-text-muted) !important;
  text-decoration: none !important;
}
#header h1 > .breadcrumbs a.root:hover { color: var(--c-primary) !important; }
#header h1 > .breadcrumbs .separator { opacity: .5 !important; margin: 0 4px !important; }

#header h1 > .current-project {
  grid-row: 2 !important;
  grid-column: 2 !important;
  font-size: var(--text-lg) !important;
  font-weight: 700 !important;
  color: var(--c-text) !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  line-height: 1.2 !important;
}

/* A top-level project has no breadcrumbs: the name sat in the empty grid's second row,
   ~9px below the middle of the badge and the search box. It takes both rows then. */
#header h1:not(:has(> .breadcrumbs)) > .current-project { grid-row: 1 / 3 !important; }

#quick-search {
  float: right !important;
  display: flex !important;
  align-items: center !important;
  gap: var(--sp-2) !important;
  padding: var(--sp-2) 0 !important;
  /* cap width so h1 has room */
  max-width: 340px !important;
}

#quick-search form { float: none !important; display: flex !important; align-items: center !important; gap: var(--sp-1) !important; margin: 0 !important; position: relative !important; }

/* Search magnifier (injected by theme.js as first child of <form>).
   Absolutely positioned inside the input; input gets left padding. */
#quick-search .rm-search-icon {
  position: absolute !important;
  left: var(--sp-3) !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  color: var(--c-text-subtle) !important;
  pointer-events: none !important;
  display: inline-flex !important;
  z-index: 1 !important;
}

#quick-search #q,
#quick-search input[type=text] {
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r) !important;
  padding: var(--sp-1) var(--sp-3) var(--sp-1) calc(var(--sp-3) + 22px) !important;
  font-size: var(--text-sm) !important;
  font-family: var(--font-sans) !important;
  background: var(--c-surface-2) !important;
  color: var(--c-text) !important;
  outline: none !important;
  width: 160px !important;
  height: 28px !important;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), width var(--t) !important;
}

#quick-search form:focus-within .rm-search-icon { color: var(--c-primary) !important; }

/* Visually-hidden utility — kept in DOM for screen readers, not shown. */
.rm-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#quick-search #q:focus,
#quick-search input[type=text]:focus {
  border-color: var(--c-primary) !important;
  box-shadow: 0 0 0 3px var(--c-primary-ring) !important;
  background: var(--c-surface) !important;
  width: 180px !important;
}

#quick-search label { display: flex !important; align-items: center !important; margin: 0 !important; }
#quick-search label a {
  color: var(--c-text-muted) !important;
  font-size: var(--text-sm) !important;
  text-decoration: none !important;
  white-space: nowrap !important;
}

#quick-search label a:hover { color: var(--c-primary) !important; }

/* project jump box */
#project-jump { float: none !important; }
/* "Jump to a project" items: core colours them with an #id selector
   (#project-jump .drdn-items > * { color: #555 !important }, hover #759FCF / #fff), which
   beat the theme's .drdn-items rules — 1.9:1 in dark mode, 2.8:1 on hover in light. */
#project-jump .drdn-items > * { color: var(--c-text) !important; }
#project-jump .drdn-items > span { color: var(--c-text-muted) !important; }
#project-jump .drdn-items > a:hover,
#project-jump .drdn-items > a:focus { background-color: var(--c-primary-light) !important; color: var(--c-text) !important; }
#project-jump .drdn-trigger {
  display: flex !important;
  align-items: center !important;
  padding: var(--sp-1) var(--sp-3) !important;
  height: 28px !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r) !important;
  font-size: var(--text-sm) !important;
  background: var(--c-surface-2) !important;
  color: var(--c-text-muted) !important;
  cursor: pointer !important;
  white-space: nowrap !important;
  max-width: 160px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* ── PROJECT TABS ────────────────────────────────────────── */
/* Override Redmine's absolute bottom positioning with normal flow */
#main-menu {
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  margin: 0 !important;
  border-top: 1px solid var(--c-border) !important;
  background: var(--c-header-bg) !important;
  padding: 0 var(--sp-6) !important;
  width: auto !important;
}

/* top-level list only — NOT the .menu-children sub-list */
#main-menu > ul {
  display: flex !important;
  list-style: none !important;
  margin: 0 !important;
  padding: 5px 0 0 !important;
  white-space: nowrap !important;
  overflow: visible !important;
}

/* Restore Redmine's hide-by-default on sub-menus */
#main-menu .menu-children {
  display: none !important;
  position: absolute !important;
  z-index: 200 !important;
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r) !important;
  box-shadow: var(--shadow-md) !important;
  min-width: 160px !important;
  padding: var(--sp-1) 0 !important;
}

#main-menu li:hover .menu-children,
#main-menu li .menu-children.visible {
  display: block !important;
}

#main-menu .menu-children li a {
  display: block !important;
  padding: var(--sp-2) var(--sp-4) !important;
  font-size: var(--text-sm) !important;
  color: var(--c-text) !important;
  background: var(--c-surface) !important; /* override hardcoded #fff per-item */
  white-space: nowrap !important;
  border-bottom: none !important;
  border-radius: 0 !important;
  font-weight: 400 !important;
}

#main-menu .menu-children li a:hover {
  background: var(--c-primary-light) !important;
  color: var(--c-primary) !important;
  border-bottom: none !important;
}

#main-menu ul li a,
#main-menu ul li span.selected {
  display: inline-flex !important;
  align-items: center !important;
  padding: var(--sp-2) var(--sp-3) !important;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  color: var(--c-text-muted) !important;
  text-decoration: none !important;
  border-bottom: 2px solid transparent !important;
  margin-bottom: -1px !important;
  transition: color var(--t-fast), border-color var(--t-fast) !important;
  white-space: nowrap !important;
}

#main-menu ul li a:hover {
  color: var(--c-primary) !important;
  border-bottom-color: var(--c-primary) !important;
  background: transparent !important;
}

/* ── "+ New object" button — circle icon in nav bar ─────── */
#main-menu a#new-object {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  margin: auto var(--sp-3) auto 0 !important;
  background: var(--c-primary) !important;
  color: var(--c-on-primary) !important;
  border: none !important;
  border-bottom: none !important;
  border-radius: var(--r-md) !important;
  font-size: 26px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  flex-shrink: 0 !important;
  transition: background var(--t-fast), transform var(--t-fast) !important;
}

#main-menu a#new-object:hover {
  background: var(--c-primary-hover) !important;
  color: var(--c-on-primary) !important;
  border-bottom: none !important;
  transform: scale(1.08) !important;
}

#main-menu ul li a.selected,
#main-menu ul li span.selected {
  color: var(--c-primary) !important;
  border-bottom-color: var(--c-primary) !important;
  font-weight: 600 !important;
  background: transparent !important; /* override Redmine's hardcoded #fff */
}

/* Gradient bars on desktop (idea from the gitmike theme, written with our tokens).
   The project tabs become a rounded bar inset from the header's edges; #header gets
   var(--sp-2) more bottom padding for it, and adjustLayout() re-measures the header.
   #header > #main-menu outranks html.dark-mode #main-menu. */
@media (min-width: 900px) {
  #top-menu { background: linear-gradient(to bottom, var(--c-topbar-grad-top), var(--c-topbar-grad-bottom)) !important; }
  /* The tab bar is in the header's normal flow (it used to be pinned to the header's
     bottom): when a narrow window wraps the tabs onto a second row, the header grows
     downwards instead of the bar growing up over the project title and the search.
     adjustLayout() re-measures the header (ResizeObserver) and moves the page below it. */
  #header:has(#main-menu ul li) { padding-bottom: calc(var(--sp-2) - 1px) !important; }
  #header > #main-menu {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    clear: both !important;
    margin-top: 14px !important;   /* keeps the bar where it was when pinned: 60px below the header top */
    padding: 0 var(--sp-2) !important;
    background: linear-gradient(to bottom, var(--c-menu-grad-top), var(--c-menu-grad-bottom)) !important;
    border: 1px solid var(--c-border) !important;
    border-bottom-color: var(--c-border-2) !important;
    border-radius: var(--r) !important;
  }
  #header > #main-menu > ul > li > a.selected {
    background: linear-gradient(to bottom, transparent, var(--c-primary-light)) !important;
  }
}

.tabs-buttons { display: none !important; }

/* ── 6. LAYOUT ───────────────────────────────────────────── */
#wrapper { background: var(--c-bg) !important; min-height: 100vh !important; }
/* Core's #wrapper { overflow: hidden } makes it a scroll container, so the sticky sidebar
   stuck to #wrapper (which never scrolls) and left with the page. clip still cuts off
   anything wider, without being a scroll container. Browsers without clip keep hidden.
   Mobile keeps responsive.css's own overflow-x: the sidebar is an overlay there. */
@media (min-width: 900px) {
  #wrapper { overflow: clip !important; }
}

#main {
  display: flex !important;
  flex-direction: row !important;   /* sidebar LEFT, content RIGHT — override Redmine's row-reverse */
  align-items: flex-start !important;
  min-height: calc(100vh - var(--total-top)) !important;
  margin-top: var(--total-top) !important; /* JS updates this accurately */
}

/* ── 7. SIDEBAR ──────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w) !important;
  min-width: var(--sidebar-w) !important;
  background: var(--c-sidebar-bg) !important;
  border-right: 1px solid var(--c-border) !important;
  position: sticky !important;
  top: var(--total-top) !important;
  height: calc(100vh - var(--total-top)) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  flex-shrink: 0 !important;
  scrollbar-width: thin !important;
  scrollbar-color: var(--c-border) transparent !important;
  transition: width var(--t), min-width var(--t), opacity var(--t) !important;
}

#sidebar::-webkit-scrollbar { width: 4px; }
/* Taller than the viewport (theme.js → fitSidebar adds .rm-sidebar-tall): drop the
   sticky viewport-tall box and its own scrollbar, let the sidebar run with the page so
   there is one scrollbar (#13). overflow-x: clip keeps wide content (iframes) inside
   without turning the sidebar back into a scroll container. Desktop only. */
@media (min-width: 900px) {
  #main.rm-sidebar-tall #sidebar {
    position: relative !important;
    top: auto !important;
    height: auto !important;
    align-self: stretch !important;
    overflow-x: clip !important;
    overflow-y: visible !important;
  }
}
#sidebar::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 2px; }

#sidebar-wrapper { padding: var(--sp-5) var(--sp-2) !important; }

/* collapsed — do NOT use opacity:0, it also hides position:fixed children.
   Desktop only: the mobile overlay ignores the collapsed setting, or it opened empty. */
@media (min-width: 900px) {
  #main.collapsiblesidebar.sidebar-collapsed #sidebar {
    width: 0 !important;
    min-width: 0 !important;
    border-right: none !important;
    overflow: hidden !important;
  }
  /* Clip floated/absolute children (e.g. #watchers .contextual > Add) that
     would otherwise escape width:0 + overflow:hidden. */
  #main.collapsiblesidebar.sidebar-collapsed #sidebar > * {
    visibility: hidden !important;
  }
}

/* hide Redmine's own sidebar toggle — replaced by our button */
#sidebar-switch-panel { display: none !important; }

/* sidebar content */
#sidebar h3 {
  font-size: var(--text-xs) !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: .08em !important;
  color: var(--c-text-subtle) !important;
  margin: 0 0 var(--sp-1) !important;
  padding-bottom: 0 !important;
}

#sidebar h3:first-child { margin-top: 0 !important; }

#sidebar ul { list-style: none !important; margin: 0 0 var(--sp-3) !important; padding: 0 !important; }

#sidebar ul li a {
  display: flex !important;
  align-items: center !important;
  padding: var(--sp-2) var(--sp-2) !important;
  font-size: var(--text-sm) !important;
  color: var(--c-text-muted) !important;
  border-radius: var(--r-sm) !important;
  text-decoration: none !important;
  transition: background var(--t-fast), color var(--t-fast) !important;
}

/* inplace_issue_editor plugin (rf_inline_editor.css). Its own --rf-* palette is light-only
   (white editors, #1f2328 text); html:root outranks its :root, so editors, dropdowns and
   buttons follow dark mode and schemes. Five colours it writes directly are remapped too. */
html:root {
  --rf-border: var(--c-border);
  --rf-focus: var(--c-primary);
  --rf-focus-ring: var(--c-focus-ring);
  --rf-error: var(--c-danger);
  --rf-success: var(--c-success);
  --rf-warning: var(--c-warning);
  --rf-text: var(--c-text);
  --rf-text-muted: var(--c-text-muted);
  --rf-bg: var(--c-surface);
  --rf-bg-hover: var(--c-surface-2);
  --rf-primary: var(--c-primary);
  --rf-primary-hover: var(--c-primary-hover);
}
.rf-edit-icon { color: var(--c-text-muted) !important; }
.rf-edit-icon:hover { background-color: var(--c-primary-light) !important; border-color: var(--c-border-2) !important; color: var(--c-primary) !important; }
.rf-ss__option--selected { background-color: var(--c-primary-light) !important; }
.rf-btn--primary { color: var(--c-on-primary) !important; }
/* In list cells the pencil (20px + margins, invisible until hover) took part in the
   centring, so the visible value sat ~13px left of its header. It now floats just right
   of the value without taking space. */
table.list td .rf-cell-wrapper { position: relative !important; }
table.list td .rf-cell-wrapper > .rf-edit-icon {
  position: absolute !important;
  left: 100% !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  margin-left: 2px !important;
}

/* Additionals plugin — "Shared dashboards" in the sidebar: the link is a flex row of its
   own, so the cube marking the system default dashboard (span.icon-cube, title "System
   default") wrapped to a line of its own under it, in the plugin's alert red. It stays
   beside the name, in a quiet colour; the tooltip keeps its meaning. */
#sidebar ul.dashboards li { display: flex !important; align-items: center !important; gap: var(--sp-1) !important; }
#sidebar ul.dashboards li > a { flex: 1 1 auto !important; min-width: 0 !important; }
#sidebar ul.dashboards li > span.icon { flex: none !important; display: inline-flex !important; padding: 0 var(--sp-1) !important; }
#sidebar ul.dashboards svg.dashboard-system-default { stroke: var(--c-text-subtle) !important; margin: 0 !important; }
/* Its dashboard blocks colour heading icons and the lock with --a-color-dark (#555):
   dark grey on a dark card. Not remapped globally — the plugin's top-menu dropdown pairs
   the same variable with a white background. */
#content .dashboard-block h3 svg,
#content #page-title svg,
#content span.dashboard-locked,
#content span.dashboard-locked svg { stroke: var(--c-text-muted) !important; }

/* Watchers list — keep avatar, name, and delete icon on one row.
   Default #sidebar ul li a { display: flex } would otherwise make each
   <a> occupy a full row, stacking them 3 high. */
#watchers ul.watchers li {
  display: flex !important;
  align-items: center !important;
  gap: var(--sp-2) !important;
  padding: 2px 0 !important;
  margin: 0 !important;
}
#watchers ul.watchers li > .avatar { flex: 0 0 auto !important; }
#watchers ul.watchers li > a.user {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  padding: 0 !important;
  display: block !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  font-size: var(--text-sm) !important;
}
#watchers ul.watchers li > a.delete {
  flex: 0 0 auto !important;
  margin-left: auto !important;
  width: 22px !important;
  height: 22px !important;
  padding: 0 !important;
}

/* Don't flex links inside labels (e.g. activity filter links) */
#sidebar ul li label a {
  display: inline !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

/* Activity filter form: Redmine sets form{display:inline} globally — override */
#activity_scope_form {
  display: block !important;
}

/* Activity filter list items: inline checkbox + label */
#activity_scope_form ul li {
  display: flex !important;
  align-items: center !important;
  gap: var(--sp-2) !important;
  padding: var(--sp-1) 0 !important;
}

/* Center the Apply button */
#activity_scope_form p:last-child {
  text-align: center !important;
  margin-top: var(--sp-3) !important;
}

#sidebar ul li a:hover,
#sidebar ul li.selected a {
  background: var(--c-primary-light) !important;
  color: var(--c-primary) !important;
}

/* sidebar toggle — fixed tab on the right edge of the sidebar */
#rm-sidebar-toggle {
  position: fixed !important;
  /* top is set by JS after measuring the header */
  top: calc(var(--total-top) + 20px) !important;
  left: calc(var(--sidebar-w) - 1px) !important;
  width: 16px !important;
  height: 40px !important;
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-left: none !important;
  border-radius: 0 var(--r) var(--r) 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  z-index: 1002 !important;
  font-size: 10px !important;
  color: var(--c-text-subtle) !important;
  padding: 0 !important;
  box-shadow: 2px 0 6px rgb(0 0 0/.08) !important;
  transition: left var(--t), background var(--t-fast), color var(--t-fast) !important;
}

/* Only where hover is real: a phone keeps :hover after a tap, so the button stayed
   filled with the accent after the sidebar was closed */
@media (hover: hover) {
  #rm-sidebar-toggle:hover {
    background: var(--c-primary) !important;
    color: var(--c-on-primary) !important;
    border-color: var(--c-primary) !important;
  }
}

body.sidebar-collapsed #rm-sidebar-toggle {
  left: 0 !important;
  border-left: 1px solid var(--c-border) !important;
  border-radius: 0 var(--r) var(--r) 0 !important;
}

/* Sidebar on the right (My account → Sidebar position; html[data-sidebar="right"], set
   before first paint, per browser). Redmine itself puts the sidebar right — the theme
   moves it left by default. Desktop only: the mobile overlay keeps opening from the left. */
@media (min-width: 900px) {
  html[data-sidebar="right"] #main { flex-direction: row-reverse !important; }
  html[data-sidebar="right"] #sidebar {
    border-right: none !important;
    border-left: 1px solid var(--c-border) !important;
  }
  html[data-sidebar="right"] #main.collapsiblesidebar.sidebar-collapsed #sidebar { border-left: none !important; }
  html[data-sidebar="right"] #rm-sidebar-toggle {
    left: auto !important;
    right: calc(var(--sidebar-w) - 1px) !important;
    border-left: 1px solid var(--c-border) !important;
    border-right: none !important;
    border-radius: var(--r) 0 0 var(--r) !important;
    box-shadow: -2px 0 6px rgb(0 0 0/.08) !important;
    transition: right var(--t), background var(--t-fast), color var(--t-fast) !important;
  }
  html[data-sidebar="right"] body.sidebar-collapsed #rm-sidebar-toggle {
    left: auto !important;
    right: 0 !important;
    border-left: 1px solid var(--c-border) !important;
    border-right: none !important;
    border-radius: var(--r) 0 0 var(--r) !important;
  }
}

/* ── HAMBURGER BUTTON (hidden on desktop) ─────────────────── */
#rm-hamburger {
  display: none;
  flex-shrink: 0;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--r);
  margin-right: auto;
  z-index: 1061;
}
#rm-hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--c-topbar-text);
  border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}
/* Animate to X when open */
body.nav-open #rm-hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.nav-open #rm-hamburger span:nth-child(2) { opacity: 0; }
body.nav-open #rm-hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── 8. CONTENT ──────────────────────────────────────────── */
#content {
  flex: 1 !important;
  padding: var(--sp-6) !important;
  min-width: 0 !important;
}

#main.nosidebar #content { padding-left: var(--sp-6) !important; }

/* ── Overview two-column layout ─────────────────────────── */
.splitcontent { align-items: flex-start !important; gap: var(--sp-4) !important; }
.splitcontentleft,
.splitcontentright {
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r-md) !important;
  padding: var(--sp-4) !important;
}
/* Project board (/projects as cards). Core lays the cards out in CSS columns, so they
   read top to bottom through the first column before the second (an alphabetical list
   reads oddly) and, with a few tall cards, the last column stays empty. A grid reads
   left to right and fills the width. Cards get the theme's radius and colours; long
   descriptions (bullet lists) are cut to a few lines, and subprojects become a compact
   list with thin dividers instead of a thick grey rule per level. */
#projects-index { columns: auto !important; }
#projects-index > ul.projects.root {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)) !important;
  gap: var(--sp-4) !important;
  align-items: stretch !important;   /* one height per row: no gaps under short cards */
}
#projects-index ul.projects li.root {
  margin: 0 !important;
  padding: var(--sp-4) var(--sp-5) !important;
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-xs) !important;
  transition: border-color var(--t-fast), box-shadow var(--t-fast) !important;
}
#projects-index ul.projects li.root:hover { border-color: var(--c-border-2) !important; box-shadow: var(--shadow-sm) !important; }
#projects-index ul.projects div.root a.project { font-size: var(--text-base) !important; margin: 0 !important; }
#projects-index ul.projects div.child a.project { font-weight: 500 !important; }
#projects-index ul.projects span.my-project,
#projects-index ul.projects span.icon-bookmarked-project { color: var(--c-text-subtle) !important; }
#projects-index ul.projects div.root .my-project svg,
#projects-index ul.projects div.root .icon-bookmarked-project svg { margin-bottom: 0 !important; }
#projects-index ul.projects div.description {
  padding-top: var(--sp-1) !important;
  color: var(--c-text-muted) !important;
  font-size: var(--text-sm) !important;
  line-height: 1.5 !important;
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 3 !important;
  line-clamp: 3;
  overflow: hidden !important;
}
#projects-index ul.projects div.child div.description { -webkit-line-clamp: 2 !important; line-clamp: 2; font-size: var(--text-xs) !important; }
#projects-index ul.projects div.description p,
#projects-index ul.projects div.description ul { margin: 0 !important; }
#projects-index li.root ul.projects {
  border-left: none !important;
  padding: 0 !important;
  margin: var(--sp-3) 0 0 !important;
  border-top: 1px solid var(--c-border) !important;
}
#projects-index ul.projects li.child { margin: 0 !important; padding: var(--sp-2) 0 !important; border-bottom: 1px solid var(--c-border) !important; }
#projects-index ul.projects li.child:last-child { border-bottom: none !important; padding-bottom: 0 !important; }
/* deeper levels: indented under their parent, one thin guide line */
#projects-index li.child ul.projects {
  margin: var(--sp-2) 0 0 var(--sp-1) !important;
  padding-left: var(--sp-3) !important;
  border-top: none !important;
  border-left: 1px solid var(--c-border) !important;
}
#projects-index li.child li.child { padding: var(--sp-1) 0 !important; border-bottom: none !important; }

/* Log time on the issue edit form: its two columns are plain rows of the fieldset, not
   cards — nested in the fieldset they boxed one field each and pushed Spent time and
   Activity out of line with Comment below. */
fieldset#log_time .splitcontentleft,
fieldset#log_time .splitcontentright {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}
fieldset#log_time .splitcontent { row-gap: 0 !important; }
/* Issue page attributes: flex-start left the two cards of a row at different heights
   and the rows touching (#14). width: 100% stops a row narrowing beside the floated
   reactions button. Scoped here: other two-column pages keep their own heights. */
div.issue.details .attributes .splitcontent {
  align-items: stretch !important;
  width: 100% !important;
  margin-bottom: var(--sp-3) !important;
}

/* ── 9. CONTEXTUAL ACTIONS ───────────────────────────────── */
.contextual {
  display: flex !important;
  align-items: center !important;
  gap: var(--sp-2) !important;
  flex-wrap: wrap !important;
  margin-bottom: var(--sp-3) !important;
}

/* ── 10. ISSUE LIST TABLE ────────────────────────────────── */
.autoscroll {
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-xs) !important;
  overflow: hidden !important;
  overflow-x: auto !important;
  margin-bottom: var(--sp-4) !important;
}

/* The table inside .autoscroll must not add its own outer border —
   the wrapper already provides one, and a second border-top creates a double line */
.autoscroll table { border-top: none !important; border-bottom: none !important; }

/* Wide issue lists scroll horizontally. Keep that scrollbar full-size and give it
   theme colours so it reads as part of the table rather than an OS artefact —
   deliberately NOT `scrollbar-width: thin`, since this bar is the only clue that
   there are more columns off to the right. */
.autoscroll { scrollbar-color: var(--c-border-2) var(--c-surface-2) !important; }
.autoscroll::-webkit-scrollbar { height: 12px !important; }
.autoscroll::-webkit-scrollbar-track {
  background: var(--c-surface-2) !important;
  border-top: 1px solid var(--c-border) !important;
}
.autoscroll::-webkit-scrollbar-thumb {
  background: var(--c-border-2) !important;
  border-radius: 5px !important;
  border: 2px solid var(--c-surface-2) !important;
}
.autoscroll::-webkit-scrollbar-thumb:hover { background: var(--c-text-subtle) !important; }

table.list {
  width: 100% !important;
  border-collapse: collapse !important;
  font-size: var(--text-sm) !important;
}

table.list thead {
  background: var(--c-surface-2) !important;
  border-bottom: 2px solid var(--c-border) !important;
}

table.list thead th {
  padding: var(--sp-2) var(--sp-3) !important;
  font-weight: 600 !important;
  font-size: var(--text-xs) !important;
  text-transform: uppercase !important;
  letter-spacing: .05em !important;
  color: var(--c-text-muted) !important;
  white-space: nowrap !important;
  border: none !important;
  text-align: left !important;
}

table.list thead th a { color: inherit !important; text-decoration: none !important; }
table.list thead th a:hover { color: var(--c-primary) !important; }

table.list tbody tr {
  border-bottom: 1px solid var(--c-border) !important;
  transition: background var(--t-fast) !important;
}

table.list tbody tr:last-child { border-bottom: none !important; }
table.list tbody tr.odd  { background: var(--c-surface) !important; }
table.list tbody tr.even { background: var(--c-surface-2) !important; }
table.list tbody tr:hover { background: var(--c-primary-light) !important; }

table.list tbody td {
  padding: var(--sp-2) var(--sp-3) !important;
  color: var(--c-text) !important;
  vertical-align: middle !important;
  border: none !important;
}

/* Long-text columns are kept to a single line with an ellipsis. Without this the
   table squeezes them to their minimum content width and one long value wraps to
   four or five lines, so every row in the list inherits that height — a list with
   a long parent task subject went to 149px per row.

   Trade-off, measured: rows drop to 61px, but a wide issue list is now wider than
   the viewport and scrolls horizontally where it used to just fit. That is the
   intended call — a compact scannable list plus a scrollbar beats five-line rows. */
/* Subtasks and subprojects: core indents tr.idnt-N cells (padding-left 24px, 40px …) with a
   chevron as background; the theme's uniform 12px cell padding cancelled the indent, so the
   chevron sat on the first letter. Indent again from the theme padding: chevron at
   12px + (N-1)·16px, text 20px after it. */
table.list tr.idnt-1 td:is(.subject, .name) { padding-left: 32px !important; background-position: 12px 50% !important; }
table.list tr.idnt-2 td:is(.subject, .name) { padding-left: 48px !important; background-position: 28px 50% !important; }
table.list tr.idnt-3 td:is(.subject, .name) { padding-left: 64px !important; background-position: 44px 50% !important; }
table.list tr.idnt-4 td:is(.subject, .name) { padding-left: 80px !important; background-position: 60px 50% !important; }
table.list tr.idnt-5 td:is(.subject, .name) { padding-left: 96px !important; background-position: 76px 50% !important; }
table.list tr.idnt-6 td:is(.subject, .name) { padding-left: 112px !important; background-position: 92px 50% !important; }
table.list tr.idnt-7 td:is(.subject, .name) { padding-left: 128px !important; background-position: 108px 50% !important; }
table.list tr.idnt-8 td:is(.subject, .name) { padding-left: 144px !important; background-position: 124px 50% !important; }
table.list tr.idnt-9 td:is(.subject, .name) { padding-left: 160px !important; background-position: 140px 50% !important; }
/* One alignment rule for every list (issues, My page, time entries, users, admin…), the
   headers follow (theme.js → alignListHeaders):
   - text left: subject and names (core), people, status, project, tracker, priority,
     category, version, login, email, identifier, activity, text-like custom fields;
   - id, dates, yes/no and counters (open / closed / total) stay centred (core);
   - hours and numeric custom fields right, like core's time entry hours. */
table.list td:is(.assigned_to, .author, .user, .last_updated_by, .status, .project, .tracker,
  .priority, .category, .fixed_version, .login, .mail, .identifier, .firstname, .lastname,
  .activity, .issue, .parent, .string, .list, .text, .link, .enumeration, .version) { text-align: left !important; }
/* two admin columns without a class: tracker → default status, custom field → format */
table.list.trackers td.name + td,
table.list.custom_fields td.name + td { text-align: left !important; }
table.list td:is(.hours, .spent_hours, .estimated_hours, .total_estimated_hours,
  .total_spent_hours, .estimated_remaining_hours, .int, .float) { text-align: right !important; }

table.list td.subject {
  max-width: 320px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
table.list td.parent-subject,
table.list td.parent {
  max-width: 260px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

table.list tbody td a {
  color: var(--c-primary) !important;
  text-decoration: none !important;
  font-weight: 500 !important;
  transition: color var(--t-fast) !important;
}

table.list tbody td a:hover {
  color: var(--c-primary-hover) !important;
  text-decoration: underline !important;
}

table.list tr.group td {
  background: var(--c-surface-2) !important;
  padding: var(--sp-2) var(--sp-4) !important;
  font-weight: 700 !important;
  font-size: var(--text-xs) !important;
  text-transform: uppercase !important;
  letter-spacing: .05em !important;
  color: var(--c-text-muted) !important;
  border-top: 2px solid var(--c-border) !important;
}

/* ── 11. ISSUE SHOW: DETAILS CARD ───────────────────────── */
.issue.details {
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-xs) !important;
  padding: var(--sp-6) !important;
  margin-bottom: var(--sp-4) !important;
  transition: box-shadow var(--t) !important;
}

.issue.details:hover { box-shadow: var(--shadow-sm) !important; }

.issue.details .subject {
  font-size: var(--text-xl) !important;
  font-weight: 700 !important;
  color: var(--c-text) !important;
  /* margin-bottom: var(--sp-3) !important; */
  line-height: 1.4 !important;
}

.issue.details .author {
  font-size: var(--text-xs) !important;
  color: var(--c-text-subtle) !important;
  margin-bottom: var(--sp-4) !important;
}

.issue.details .author a { color: var(--c-text-muted) !important; font-weight: 500 !important; }

/* Attributes grid */
.attributes table { width: 100% !important; border-collapse: collapse !important; }

.attributes td.label {
  font-size: var(--text-xs) !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: .05em !important;
  color: var(--c-text-subtle) !important;
  padding: var(--sp-2) var(--sp-4) var(--sp-2) 0 !important;
  white-space: nowrap !important;
  border: none !important;
  width: 38% !important;
}

.attributes td.value {
  font-size: var(--text-sm) !important;
  color: var(--c-text) !important;
  padding: var(--sp-2) 0 !important;
  border: none !important;
}

/* Description section */
.issue.details .description {
  margin-top: var(--sp-4) !important;
  padding-top: var(--sp-4) !important;
  border-top: 1px solid var(--c-border) !important;
}

.issue.details .description > p > strong,
.issue.details hr + p strong {
  font-size: var(--text-xs) !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: .05em !important;
  color: var(--c-text-subtle) !important;
  display: block !important;
  margin-bottom: var(--sp-2) !important;
}

/* ── 12. HISTORY / JOURNALS CARD ─────────────────────────── */
#history {
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-xs) !important;
  padding: var(--sp-6) !important;
  margin-bottom: var(--sp-4) !important;
}

#history .tabs { border-bottom: 1px solid var(--c-border) !important; margin-bottom: var(--sp-4) !important; }

#history .tabs ul { display: flex !important; list-style: none !important; margin: 0 !important; padding: 0 !important; }

#history .tabs ul li a {
  display: inline-flex !important;
  align-items: center !important;
  padding: var(--sp-3) var(--sp-4) !important;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  color: var(--c-text-muted) !important;
  text-decoration: none !important;
  border-bottom: 2px solid transparent !important;
  margin-bottom: -1px !important;
  transition: color var(--t-fast), border-color var(--t-fast) !important;
}

#history .tabs ul li a:hover,
#history .tabs ul li.selected a {
  color: var(--c-primary) !important;
  border-bottom-color: var(--c-primary) !important;
}

.journal {
  border-bottom: 1px solid var(--c-border) !important;
  padding: var(--sp-4) var(--sp-2) !important;
  border-radius: var(--r) !important;
  transition: background var(--t-fast), padding var(--t-fast) !important;
}

.journal:last-child { border-bottom: none !important; }

.journal:hover {
  background: var(--c-surface-2) !important;
  padding-left: var(--sp-4) !important;
  padding-right: var(--sp-4) !important;
}

/* Redmine core hardcodes light colours on the journal header — #f6f7f8 for the
   strip, #DDEEFF for the one you jumped to via anchor, #666 for the timestamp.
   None of them react to dark mode, so the header stayed white on a dark page.
   Re-expressed as tokens, which already carry both palettes. */
.journals h4.journal-header {
  background: var(--c-surface-2) !important;
  color: var(--c-text) !important;
  border-radius: var(--r-sm) !important;
}
.journals div:target h4.journal-header { background: var(--c-primary-light) !important; }
.journals h4.journal-header .update-info { color: var(--c-text-muted) !important; }

/* ── 13. SUBTASKS & RELATIONS CARDS ─────────────────────── */
#issue_tree, #relations {
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r-md) !important;
  padding: var(--sp-4) var(--sp-5) !important;
  margin: var(--sp-4) 0 !important;
  box-shadow: var(--shadow-xs) !important;
}

/* ── 14. BADGES ──────────────────────────────────────────── */
.badge {
  display: inline-flex !important;
  align-items: center !important;
  padding: .125rem var(--sp-2) !important;
  border-radius: var(--r-sm) !important;
  font-size: var(--text-xs) !important;
  font-weight: 600 !important;
  line-height: 1.5 !important;
  white-space: nowrap !important;
}

.badge-private { background: rgba(239,68,68,.1) !important; color: var(--c-badge-private-text) !important; }

/* Icon-only anchors (delete-watcher, new-category, new-version, etc):
   hide label text, keep SVG, constrain to a small square button. Higher-
   specificity variants so this beats #sidebar ul li a and other context
   rules that set font-size / width on anchors. */
a.icon-only,
#sidebar a.icon-only,
#sidebar ul li a.icon-only,
#content a.icon-only {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 24px !important;
  height: 24px !important;
  padding: 0 !important;
  border-radius: var(--r-sm) !important;
  font-size: 0 !important;
  line-height: 1 !important;
  text-decoration: none !important;
  flex: 0 0 auto !important;
  vertical-align: middle !important;
  transition: background var(--t-fast), color var(--t-fast) !important;
}
a.icon-only:hover {
  background: var(--c-primary-light) !important;
  color: var(--c-primary) !important;
}

/* icon-only + icon-add (New category / New version next to form selects):
   give them a pale-cyan chip look so they don't read as orphaned glyphs. */
a.icon-only.icon-add,
#content a.icon-only.icon-add {
  background: var(--c-primary-light) !important;
  border: 1px solid rgba(8,145,178,.25) !important;
}
a.icon-only.icon-add:hover {
  background: var(--c-primary) !important;
  border-color: var(--c-primary) !important;
}
a.icon-only.icon-add:hover .icon-svg { stroke: var(--c-on-primary) !important; }
a.icon-only .icon-svg,
a.icon-only > svg,
#sidebar a.icon-only .icon-svg,
#sidebar a.icon-only > svg {
  font-size: initial !important;
  width: 14px !important;
  height: 14px !important;
  vertical-align: middle !important;
  flex: 0 0 auto !important;
}
a.icon-only .icon-label { display: none !important; }


/* Priority icons (idea from the Opale theme, own code): a Jira-like arrow before the
   priority in issue lists and on the issue page. Redmine marks rows and the issue with
   priority-<position_name>: highest, high2, high3 … default … low3, low2, lowest
   (IssuePriority#css_classes). Shapes are masks, colours come from tokens, so dark mode
   and schemes follow. Icon colours reach at least 3:1 on the surface (WCAG 1.4.11). */
.priority-highest { --rm-prio-color: var(--c-prio-highest); --rm-prio-icon: var(--rm-icon-up2); }
[class*="priority-high"]:not(.priority-highest) { --rm-prio-color: var(--c-prio-high); --rm-prio-icon: var(--rm-icon-up); }
.priority-default { --rm-prio-color: var(--c-text-subtle); --rm-prio-icon: var(--rm-icon-eq); }
[class*="priority-low"]:not(.priority-lowest) { --rm-prio-color: var(--c-prio-low); --rm-prio-icon: var(--rm-icon-down); }
.priority-lowest { --rm-prio-color: var(--c-prio-lowest); --rm-prio-icon: var(--rm-icon-down2); }
table.list tr.issue td.priority::before,
div.issue.details .attribute.priority .value::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 5px;
  vertical-align: -2px;
  background-color: var(--rm-prio-color, var(--c-text-subtle));
  -webkit-mask: var(--rm-prio-icon, var(--rm-icon-eq)) center / contain no-repeat;
  mask: var(--rm-prio-icon, var(--rm-icon-eq)) center / contain no-repeat;
}

/* Tracker markers (idea from the Opale theme, own code): a dot in the tracker colour
   before the tracker name in issue lists and before the issue page title (a tint behind
   the #id was tried and dropped: it took the id text below 4.5:1 in light schemes).
   Colours cycle a 6-colour palette by tracker id (tracker-1 …
   tracker-24), so they are stable per tracker but not tied to a meaning. */
.tracker-1, #content:has(> div.issue.tracker-1) { --rm-trk: var(--c-trk-1); }
.tracker-2, #content:has(> div.issue.tracker-2) { --rm-trk: var(--c-trk-2); }
.tracker-3, #content:has(> div.issue.tracker-3) { --rm-trk: var(--c-trk-3); }
.tracker-4, #content:has(> div.issue.tracker-4) { --rm-trk: var(--c-trk-4); }
.tracker-5, #content:has(> div.issue.tracker-5) { --rm-trk: var(--c-trk-5); }
.tracker-6, #content:has(> div.issue.tracker-6) { --rm-trk: var(--c-trk-6); }
.tracker-7, #content:has(> div.issue.tracker-7) { --rm-trk: var(--c-trk-1); }
.tracker-8, #content:has(> div.issue.tracker-8) { --rm-trk: var(--c-trk-2); }
.tracker-9, #content:has(> div.issue.tracker-9) { --rm-trk: var(--c-trk-3); }
.tracker-10, #content:has(> div.issue.tracker-10) { --rm-trk: var(--c-trk-4); }
.tracker-11, #content:has(> div.issue.tracker-11) { --rm-trk: var(--c-trk-5); }
.tracker-12, #content:has(> div.issue.tracker-12) { --rm-trk: var(--c-trk-6); }
.tracker-13, #content:has(> div.issue.tracker-13) { --rm-trk: var(--c-trk-1); }
.tracker-14, #content:has(> div.issue.tracker-14) { --rm-trk: var(--c-trk-2); }
.tracker-15, #content:has(> div.issue.tracker-15) { --rm-trk: var(--c-trk-3); }
.tracker-16, #content:has(> div.issue.tracker-16) { --rm-trk: var(--c-trk-4); }
.tracker-17, #content:has(> div.issue.tracker-17) { --rm-trk: var(--c-trk-5); }
.tracker-18, #content:has(> div.issue.tracker-18) { --rm-trk: var(--c-trk-6); }
.tracker-19, #content:has(> div.issue.tracker-19) { --rm-trk: var(--c-trk-1); }
.tracker-20, #content:has(> div.issue.tracker-20) { --rm-trk: var(--c-trk-2); }
.tracker-21, #content:has(> div.issue.tracker-21) { --rm-trk: var(--c-trk-3); }
.tracker-22, #content:has(> div.issue.tracker-22) { --rm-trk: var(--c-trk-4); }
.tracker-23, #content:has(> div.issue.tracker-23) { --rm-trk: var(--c-trk-5); }
.tracker-24, #content:has(> div.issue.tracker-24) { --rm-trk: var(--c-trk-6); }
table.list tr.issue td.tracker::before,
#content:has(> div.issue.details) > h2::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
  background: var(--rm-trk, var(--c-text-subtle));
}
#content:has(> div.issue.details) > h2::before { width: 10px; height: 10px; margin-right: 8px; vertical-align: 2px; }

/* ── CALENDAR & GANTT ────────────────────────────────────────
   Adapted from redmine-shadcn-theme (MIT, © 2026 Techolve), whose designs follow ReUI's
   Event Calendar and Gantt; translated from Tailwind to plain CSS and to our tokens, so
   light, dark and every scheme follow. #content outranks the older dark-mode and scheme
   rules, and core's inline styles (header background, marker widths) need !important. */

/* Calendar: Redmine 6's ul.cal is a CSS grid (week number + 7 days). Rounded corners on
   the four corner cells only — overflow: hidden would cut the issue tooltips. */
#content ul.cal, #content p.cal.legend {
  --cal-start: var(--c-info);
  --cal-end: var(--c-warning);
  --cal-both: color-mix(in srgb, var(--c-danger) 50%, var(--c-info));
}
#content ul.cal {
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-xs) !important;
  grid-template-columns: 2.5rem repeat(7, 1fr) !important;
}
#content ul.cal > li { border: 0 !important; }
#content ul.cal > li:first-child { border-top-left-radius: var(--r-md); }
#content ul.cal > li.calhead:nth-child(8) { border-top-right-radius: var(--r-md); }
#content ul.cal > li.week-number:nth-last-child(8) { border-bottom-left-radius: var(--r-md); }
#content ul.cal > li:last-child { border-bottom-right-radius: var(--r-md); }
#content .cal .calhead {
  background: transparent !important;
  color: var(--c-text-muted) !important;
  font-size: var(--text-xs) !important;
  font-weight: 500 !important;
  text-align: left !important;
  padding: .5rem .625rem !important;
}
#content .cal .week-number {
  background: transparent !important;
  color: var(--c-text-muted) !important;
  font-size: var(--text-xs) !important;
  text-align: center !important;
  padding: .5rem .25rem !important;
}
#content .cal .week-number:not(.calhead) { border-top: 1px solid var(--c-border) !important; }
#content .cal .calbody {
  display: flex !important;
  flex-direction: column !important;
  gap: .25rem !important;
  background: transparent !important;
  border: 0 !important;
  border-left: 1px solid var(--c-border) !important;
  border-top: 1px solid var(--c-border) !important;
  box-shadow: none !important;
  min-height: 6.5rem !important;
  padding: .375rem !important;
  line-height: 1.35 !important;
  color: var(--c-text) !important;
}
#content .cal .calbody.other-month { background: color-mix(in srgb, var(--c-surface-2) 60%, transparent) !important; }
#content .cal .calbody.nwday:not(.other-month),
#content .cal .calbody.today { background: transparent !important; }
#content .cal .calbody p.day-num {
  order: 99;
  margin: auto 0 0 !important;
  align-self: flex-end;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 .25rem !important;
  border-radius: 999px;
  font-size: var(--text-xs) !important;
  font-weight: 500 !important;
  color: var(--c-text-muted) !important;
}
#content .cal .calbody.other-month p.day-num { color: var(--c-text-subtle) !important; opacity: .7; }
#content .cal .calbody.today p.day-num { background: var(--c-text) !important; color: var(--c-surface) !important; font-weight: 600 !important; opacity: 1; }
/* Issue chips: tint and left stripe in the start / end / start-and-end colour; the link
   keeps the text colour (the chip colour as text would miss 4.5:1 in light mode). */
#content .cal .calbody div.issue {
  --chip: var(--cal-start);
  display: block !important;
  margin: 0 !important;
  padding: .25rem .375rem !important;
  border: 0 !important;
  border-radius: var(--r-sm) !important;
  box-shadow: inset 3px 0 0 var(--chip) !important;
  background: color-mix(in srgb, var(--chip) 12%, var(--c-surface)) !important;
  color: var(--c-text) !important;
  font-size: var(--text-xs) !important;
  word-break: break-word;
}
#content .cal .calbody div.issue.ending { --chip: var(--cal-end); }
#content .cal .calbody div.issue.starting.ending { --chip: var(--cal-both); }
#content .cal .calbody div.issue:hover { background: color-mix(in srgb, var(--chip) 22%, var(--c-surface)) !important; }
#content .cal .calbody div.issue > svg.icon-svg { stroke: var(--chip) !important; width: .875rem; height: .875rem; vertical-align: -.1875rem; margin-right: .125rem; }
#content .cal .calbody div.issue > a.issue { color: var(--c-text) !important; font-weight: 500 !important; }
#content .cal .calbody div.issue:has(> a.issue.closed) { opacity: .6; }
/* Tooltips in the last two columns open to the left (8 cells per row: week + 7 days) */
#content .cal .calbody:nth-child(8n+7) div.tooltip:hover span.tip,
#content .cal .calbody:nth-child(8n) div.tooltip:hover span.tip { left: auto !important; right: 0 !important; }
#content .cal .calbody > span.icon {
  display: flex !important;
  align-items: center;
  gap: .25rem;
  padding: .25rem .375rem !important;
  border-radius: var(--r-sm);
  background: var(--c-surface-2) !important;
  font-size: var(--text-xs) !important;
  font-weight: 500 !important;
}
#content .cal .calbody > span.icon a { color: var(--c-text) !important; }
#content p.cal.legend {
  display: flex !important;
  flex-wrap: wrap;
  gap: .25rem 1rem;
  margin-top: .75rem !important;
  font-size: var(--text-xs) !important;
  color: var(--c-text-muted) !important;
}
#content p.cal.legend > span { --chip: var(--cal-start); align-items: center; gap: .375rem; }
#content p.cal.legend > span.ending { --chip: var(--cal-end); }
#content p.cal.legend > span.starting.ending { --chip: var(--cal-both); }
#content p.cal.legend > span > svg.icon-svg { stroke: var(--chip) !important; width: .875rem; height: .875rem; }

/* Gantt: positions are inline, in 20px rows (16px content + 4px). theme.js → initGantt
   widens rows to 28px and stores the first row's top in --gantt-row-start and the row
   height in --gantt-row-height (without JS the rows stay 20px). */
#content table.gantt-table {
  --gantt-row-start: 44px;
  --gantt-row-height: 20px;
  --gantt-row-padding: 2px;
  --gantt-bar: var(--c-primary);
  --gantt-bar-todo: color-mix(in srgb, var(--gantt-bar) 22%, var(--c-surface));
  --gantt-bar-late: color-mix(in srgb, var(--c-danger) 75%, var(--c-surface));
  --gantt-summary: color-mix(in srgb, var(--c-text-muted) 30%, var(--c-surface));
  --gantt-summary-done: var(--c-text-muted);
  --gantt-row-line: color-mix(in srgb, var(--c-border) 70%, transparent);
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r-md) !important;
  overflow: hidden;
  border-collapse: separate !important;
  border-spacing: 0;
}
#content table.gantt-table td { border-color: var(--c-border) !important; }
#content .gantt_hdr[style*="background"] { background: color-mix(in srgb, var(--c-surface-2) 50%, var(--c-surface)) !important; }
#content .gantt_hdr,
#content #gantt_area .gantt_hdr,
#content .gantt_subjects_container:not(.draw_selected_columns) .gantt_hdr,
#content .last_gantt_selected_column .gantt_hdr { border-color: var(--c-border) !important; }
#content .gantt_hdr {
  color: var(--c-text-muted) !important;
  font-size: var(--text-xs) !important;
  font-weight: 500 !important;
  border-top: 0 !important;
}
#content #gantt_area .gantt_hdr a { color: var(--c-text) !important; font-weight: 600 !important; }
#content #gantt_area .gantt_hdr a:hover { text-decoration: none !important; color: var(--c-primary) !important; }
#content .gantt_hdr.nwday { background: color-mix(in srgb, var(--c-surface-2) 60%, transparent) !important; color: var(--c-text-muted) !important; }
#content .gantt_hdr_selected_column_name { color: var(--c-text-muted) !important; font-size: var(--text-xs) !important; font-weight: 500 !important; }
#content #gantt_area { background-color: var(--c-surface) !important; }
/* Row lines: one per row height from the first row down, none in the header */
#content #gantt_area,
#content .gantt_subjects,
#content .gantt_selected_column_content {
  background-image: repeating-linear-gradient(to bottom,
    transparent 0 calc(var(--gantt-row-height) - 1px),
    var(--gantt-row-line) calc(var(--gantt-row-height) - 1px) var(--gantt-row-height));
  background-position: 0 calc(var(--gantt-row-start) - var(--gantt-row-padding) + 1px - var(--gantt-row-height));
  background-clip: content-box;
  padding-top: calc(var(--gantt-row-start) - var(--gantt-row-padding) + 1px);
  box-sizing: border-box;
}
#content .gantt_subjects,
#content .gantt_selected_column_content { height: 100%; }
#content .gantt_subjects div,
#content .gantt_selected_column_content div { color: var(--c-text); }
#content .gantt_subjects { font-size: .8125rem; }
/* Long subjects end in "…" inside the column: core sets an inline width that ignores the
   padding, so width: auto and the right edge from `right` (follows column resizing) */
#content .gantt_subjects form > div { width: auto !important; right: .75rem; margin-left: .5rem; text-overflow: ellipsis; }
#content .gantt_subjects form > div > span.icon { display: inline !important; }
#content .gantt_subjects form > div > span.icon > svg.icon-svg { vertical-align: middle; margin-right: .125rem; }
#content .gantt_selected_column_content > div { padding-left: .5rem; padding-right: .25rem; text-overflow: ellipsis; color: var(--c-text-muted); }
#content .gantt_subjects :is(div.issue-subject, div.version-name, div.project-name) { border-radius: var(--r-sm); }
#content .gantt_subjects div.issue-subject:hover { background: var(--c-surface-2); }
#content .gantt_subjects :is(div.version-name, div.project-name) { font-weight: 600; }
#content .gantt_subjects .expander { color: var(--c-text-muted); }
/* Bars */
#content .task { color: var(--c-text-muted); }
#content .task.label { font-size: var(--text-xs); padding-left: .5rem; }
#content .task.label:is(.project, .version) { color: var(--c-text); font-weight: 600; }
#content .task.leaf:is(.task_todo, .task_late, .task_done) { height: 14px; margin-top: 1px; border: 0; border-radius: 4px; box-sizing: border-box; }
#content .task.leaf.task_todo { background: var(--gantt-bar-todo); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gantt-bar) 35%, transparent); }
#content .task.leaf.task_late { background: var(--gantt-bar-late); border-radius: 4px 0 0 4px; }
#content .task.leaf.task_done { background: var(--gantt-bar); border-radius: 4px 0 0 4px; }
#content .task.parent:is(.task_todo, .task_late, .task_done) { height: 4px; margin-top: 6px; border: 0; border-radius: 999px; }
#content .task.parent.task_todo { background: var(--gantt-summary); }
#content .task.parent.task_late { background: var(--c-danger); }
#content .task.parent.task_done { background: var(--gantt-summary-done); }
#content .task.parent.marker:is(.starting, .ending) {
  background: var(--gantt-summary-done);
  width: 3px !important;
  height: 12px;
  margin-left: -1px;
  top: 2px;
  border-radius: 2px;
}
#content .task:is(.version, .project):is(.task_todo, .task_late, .task_done) { height: 4px; margin-top: 6px; border: 0; border-radius: 999px; background-image: none; }
#content .task:is(.version, .project).task_todo { background-color: var(--gantt-summary); }
#content .task:is(.version, .project).task_late { background-color: var(--c-danger); }
#content .task:is(.version, .project).task_done { background-color: var(--gantt-summary-done); }
#content .task:is(.version, .project).marker {
  background: var(--c-text);
  width: 8px !important;
  height: 8px;
  margin-top: 4px;
  margin-left: -4px;
  border-radius: 1px;
  transform: rotate(45deg);
}
#content .task.project.marker { background: var(--gantt-bar); }
#content #today_line { border-left: 1.5px solid var(--c-danger) !important; z-index: 5; }
#content #today_line::before {
  content: "";
  position: absolute;
  top: -3px;
  left: -4.25px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--c-danger);
}
#content :is(.version-behind-schedule, .issue-behind-schedule) a { color: var(--c-syn-number); }
#content :is(.version-overdue, .issue-overdue, .project-overdue) a { color: var(--c-syn-tag); }
#content.gantt_content table.gantt-table { margin-bottom: .75rem; }

/* Selection caret (theme.js → initSelectionCaret): browsers draw no caret while text is
   selected; this line marks the end that Shift+arrows move. Under reduced motion the
   global rule stops the animation and, without a fill mode, the line stays visible. */
#rm-sel-caret {
  position: absolute;
  display: none;
  width: 2px;
  background: var(--c-primary);
  border-radius: 1px;
  pointer-events: none;
  z-index: 10000;
  animation: rm-sel-blink 1.06s steps(1) infinite;
}
@keyframes rm-sel-blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

/* My page (and the dashboard plugin's project overview, same markup): the three block
   columns are .splitcontent* layout columns, which the theme otherwise draws as cards — a
   card around the cards, and an empty card for an empty column. Plain columns here; they
   show a dashed outline only while a block is being dragged (core adds .dragging). The
   blocks' floated actions (.contextual) had a 12px bottom margin that reached below the
   heading, so the table's .autoscroll (a new formatting context) shrank beside it by
   ~100px and its last columns scrolled. */
#my-page .block-receiver {
  background: transparent !important;
  border: 1px solid transparent !important;
  border-radius: var(--r-md) !important;
  box-shadow: none !important;
  padding: 0 !important;
}
.dragging #my-page .block-receiver { border: 1px dashed var(--c-border-2) !important; }
#my-page .mypage-box > .contextual { margin-bottom: 0 !important; }

/* Core gives dashboard blocks (My page, the project overview of the dashboard plugin),
   issue tooltips and the wiki text diff a fixed #505050 text (and #fff / #f6f6f6
   backgrounds): in dark mode and dark schemes "Manager:" and other plain text in those
   blocks was dark grey on a dark card. */
.mypage-box { color: var(--c-text) !important; }
div.tooltip span.tip {
  background: var(--c-surface) !important;
  color: var(--c-text) !important;
  border-color: var(--c-border-2) !important;
  box-shadow: var(--shadow-md) !important;
}
.text-diff { background: var(--c-surface-2) !important; color: var(--c-text) !important; }

/* ── 15. BUTTONS ─────────────────────────────────────────── */
a.icon.new-issue,
a.icon.icon-add,
.contextual a.icon {
  display: inline-flex !important;
  align-items: center !important;
  gap: var(--sp-2) !important;
  padding: var(--sp-2) var(--sp-3) !important;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  border-radius: var(--r) !important;
  text-decoration: none !important;
  border: 1px solid var(--c-border) !important;
  background: var(--c-surface) !important;
  color: var(--c-text) !important;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast) !important;
  white-space: nowrap !important;
}

a.icon.new-issue,
a.icon.icon-add {
  background: var(--c-primary-light) !important;
  color: var(--c-primary) !important;
  border-color: rgba(8,145,178,.25) !important;
  font-weight: 600 !important;
}
/* Default state: icon stroke matches text (indigo) */
a.icon.new-issue .icon-svg,
a.icon.icon-add .icon-svg { stroke: var(--c-primary) !important; }

a.icon.new-issue:hover,
a.icon.icon-add:hover {
  background: var(--c-primary) !important;
  color: var(--c-on-primary) !important;
  border-color: var(--c-primary) !important;
  box-shadow: var(--shadow-sm) !important;
}
/* Hover state: icon stroke white (override Redmine's red) */
a.icon.new-issue:hover .icon-svg,
a.icon.icon-add:hover .icon-svg { stroke: var(--c-on-primary) !important; }

/* Core colours every icon #169 via svg.icon-svg; same specificity, no !important,
   so core's more specific icon colours (error, ok, readonly, flash) still win. */
svg.icon-svg { stroke: var(--c-icon); }
svg.icon-svg-filled { fill: var(--c-icon); stroke: none; }

/* All other icon links: use theme color instead of Redmine's red on hover */
.contextual a.icon:hover { background: var(--c-surface-2) !important; border-color: var(--c-border-2) !important; }
.contextual a.icon:hover .icon-svg { stroke: var(--c-primary) !important; }
a.icon:hover .icon-svg { stroke: var(--c-primary) !important; }

input[type=submit], button.button {
  display: inline-flex !important;
  align-items: center !important;
  gap: var(--sp-2) !important;
  padding: 0 var(--sp-4) !important;
  height: 36px !important;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  font-family: var(--font-sans) !important;
  border-radius: var(--r) !important;
  cursor: pointer !important;
  border: 1px solid var(--c-border) !important;
  background: var(--c-surface-2) !important;
  color: var(--c-text) !important;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast) !important;
  line-height: 1 !important;
}

/* Cancel / secondary action links adjacent to submit buttons */
input[type=submit] + a, button.button + a, .submit + a {
  display: inline-flex !important;
  align-items: center !important;
  height: 36px !important;
  padding: 0 var(--sp-4) !important;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  border-radius: var(--r) !important;
  border: 1px solid var(--c-border) !important;
  color: var(--c-text-muted) !important;
  text-decoration: none !important;
  background: transparent !important;
  cursor: pointer !important;
  transition: background var(--t-fast), color var(--t-fast) !important;
}
input[type=submit] + a:hover, button.button + a:hover {
  background: var(--c-surface-2) !important;
  color: var(--c-text) !important;
}

/* input[type=button] kept as inline-block so value arrows (→ ← ⇈ ↑ ↓ ⇊) render correctly */
input[type=button] {
  display: inline-block !important;
  padding: var(--sp-1) var(--sp-2) !important;
  font-size: var(--text-base) !important;
  font-family: inherit !important;
  border-radius: var(--r) !important;
  cursor: pointer !important;
  border: 1px solid var(--c-border) !important;
  background: var(--c-surface-2) !important;
  color: var(--c-text) !important;
  transition: background var(--t-fast), border-color var(--t-fast) !important;
  line-height: 1 !important;
  text-align: center !important;
  vertical-align: middle !important;
}

input[type=submit] {
  background: var(--c-primary) !important;
  color: var(--c-on-primary) !important;
  border-color: var(--c-primary) !important;
}

input[type=submit]:hover {
  background: var(--c-primary-hover) !important;
  border-color: var(--c-primary-hover) !important;
  box-shadow: var(--shadow-sm) !important;
}

input[type=button]:hover, button.button:hover {
  background: var(--c-border) !important;
}

/* ── 16. FORM INPUTS ─────────────────────────────────────── */
/* Shared border/color — keep height/padding compatible with Redmine's 24px default */
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=search], input[type=url], input[type=date], textarea {
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r) !important;
  padding: 4px var(--sp-3) !important;
  font-size: var(--text-sm) !important;
  font-family: var(--font-sans) !important;
  background: var(--c-surface) !important;
  color: var(--c-text) !important;
  outline: none !important;
  transition: border-color var(--t-fast), box-shadow var(--t-fast) !important;
}

/* Select: keep Redmine's original height:24px, just restyle border/colors.
   Core draws the dropdown arrow as a background-image (appearance: none +
   chevron-down.svg) — a `background:` shorthand here wiped it on every select, so
   only background-color is set and the theme's own chevron is drawn. */
select {
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r) !important;
  padding: 2px 28px 2px var(--sp-2) !important;
  font-size: var(--text-sm) !important;
  font-family: var(--font-sans) !important;
  background-color: var(--c-surface) !important;
  background-image: var(--c-select-arrow) !important;
  background-repeat: no-repeat !important;
  background-position: right 9px center !important;
  background-size: 12px 12px !important;
  color: var(--c-text) !important;
  outline: none !important;
  transition: border-color var(--t-fast), box-shadow var(--t-fast) !important;
  /* Do NOT set width:100% globally — breaks narrow operator selects */
}
/* Issue filters: "Add filter" + its select sat side by side only while the select was
   ~204px; the arrow's padding pushed it under the label (and longer labels, e.g.
   Serbian "Додај филтер", break it sooner). A flex row keeps them together and lets
   the select give way — its popup still shows the options at full width. */
@media (min-width: 900px) {   /* mobile keeps the label above a full-width select */
  div.add-filter { display: flex !important; align-items: center !important; justify-content: flex-end !important; gap: var(--sp-2) !important; }
  div.add-filter label { flex: none !important; white-space: nowrap !important; }
  div.add-filter select { flex: 0 1 auto !important; min-width: 0 !important; max-width: 100% !important; }
}

/* List boxes (multiple / size > 1) show their options — no arrow */
select[multiple], select[size]:not([size="1"]) {
  background-image: none !important;
  padding-right: var(--sp-2) !important;
}

/* height: auto WITHOUT !important — dragging the resize grip sets an inline height,
   and an !important height silently overrode it, so no textarea could be resized */
textarea {
  height: auto;
  min-height: 80px !important;
  resize: vertical !important;
}

/* File inputs: the "No file chosen" label is core #333, invisible on dark surfaces */
html.dark-mode input[type=file] { color: var(--c-text-muted) !important; }

/* @mention autocomplete (core tribute.js): #efefef list with inherited text — white on
   near-white in dark mode. Themed in both modes so it matches the other dropdowns. */
.tribute-container ul {
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r) !important;
  box-shadow: var(--shadow-md) !important;
  overflow: hidden !important;
}
.tribute-container li { color: var(--c-text) !important; }
.tribute-container li.highlight,
html.dark-mode .tribute-container li.highlight {   /* beats the search-result .highlight amber */
  background: var(--c-primary-light) !important;
  color: var(--c-text) !important;
  box-shadow: inset 3px 0 0 var(--c-primary) !important;
}
.tribute-container li.no-match { color: var(--c-text-muted) !important; }

input[type=text]:focus, input[type=email]:focus, input[type=password]:focus,
input[type=number]:focus, input[type=search]:focus, input[type=url]:focus,
input[type=date]:focus, textarea:focus {
  border-color: var(--c-primary) !important;
  box-shadow: 0 0 0 3px var(--c-primary-ring) !important;
}

select:focus { border-color: var(--c-primary) !important; }

input[type=text]:hover:not(:focus),
input[type=email]:hover:not(:focus),
input[type=date]:hover:not(:focus),
select:hover:not(:focus) { border-color: var(--c-border-2) !important; }

/* Multi-select custom field editor (core's own .check_box_group) - core hardcodes a plain
   white background, gray border and no radius regardless of theme, so it stood out against
   every other themed input. Match the same border/radius/background/text color. */
.check_box_group {
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r) !important;
  background: var(--c-surface) !important;
  color: var(--c-text) !important;
}

label { font-size: var(--text-sm) !important; font-weight: 500 !important; color: var(--c-text) !important; }

/* ── 17. FLASH MESSAGES ──────────────────────────────────── */
#flash_notice, #flash_error, #flash_warning, div.flash {
  padding: var(--sp-3) var(--sp-4) !important;
  border-radius: var(--r) !important;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  margin-bottom: var(--sp-4) !important;
  border: 1px solid transparent !important;
  display: flex !important;
  align-items: center !important;
  gap: var(--sp-2) !important;
}
/* …but a flash that Redmine or a plugin hid inline (jQuery .hide(), e.g. Agile's
   empty #agile-board-errors) must stay hidden — display:flex !important beat it. */
#flash_notice[style*="display: none"], #flash_error[style*="display: none"],
#flash_warning[style*="display: none"], div.flash[style*="display: none"],
div.flash[style*="display:none"] { display: none !important; }

#flash_notice, div.flash.notice {
  background: rgba(16,185,129,.1) !important;
  border-color: rgba(16,185,129,.3) !important;
  color: var(--c-flash-success-text) !important;
}

#flash_error, div.flash.error {
  background: rgba(239,68,68,.1) !important;
  border-color: rgba(239,68,68,.3) !important;
  color: var(--c-flash-error-text) !important;
}

#flash_warning, div.flash.warning {
  background: rgba(245,158,11,.1) !important;
  border-color: rgba(245,158,11,.3) !important;
  color: var(--c-flash-warning-text) !important;
}

/* ── 18. PAGINATION ──────────────────────────────────────── */
.pagination {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: var(--sp-1) !important;
  padding: var(--sp-4) 0 !important;
  flex-wrap: wrap !important;
}

.pagination a, .pagination span.current, .pagination em.current {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 32px !important;
  height: 32px !important;
  padding: 0 var(--sp-2) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r) !important;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  color: var(--c-text-muted) !important;
  text-decoration: none !important;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast) !important;
  background: var(--c-surface) !important;
}

.pagination a:hover {
  background: var(--c-primary-light) !important;
  color: var(--c-primary) !important;
  border-color: var(--c-primary) !important;
}

.pagination span.current, .pagination em.current {
  background: var(--c-primary) !important;
  color: var(--c-on-primary) !important;
  border-color: var(--c-primary) !important;
}

/* ── 19. GLOBAL LINKS ────────────────────────────────────── */
a { color: var(--c-primary) !important; text-decoration: none !important; transition: color var(--t-fast) !important; }
a:hover { color: var(--c-primary-hover) !important; }

/* ── 20. WIKI CONTENT ────────────────────────────────────── */
.wiki { font-size: var(--text-sm) !important; line-height: 1.75 !important; color: var(--c-text) !important; }
.wiki p { margin: 0 0 var(--sp-3) !important; }

.wiki code, code {
  font-size: .8125rem !important;
  background: var(--c-surface-2) !important;
  padding: .1em .35em !important;
  border-radius: var(--r-sm) !important;
  border: 1px solid var(--c-border) !important;
  color: var(--c-text) !important;
}

.wiki pre {
  background: var(--c-surface-2) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r) !important;
  padding: var(--sp-4) !important;
  overflow-x: auto !important;
  margin: var(--sp-3) 0 !important;
}

.wiki pre code { background: none !important; border: none !important; padding: 0 !important; }

/* ── 21. PROGRESS BAR ────────────────────────────────────── */
/* Preserve Redmine's original 80px float — .attributes table { width:100% } would override */
table.progress {
  width: 80px !important;
  float: left !important;
  height: 1em !important;
  border-collapse: collapse !important;
  margin: 1px 6px 1px 0 !important;
}
table.progress td { padding: 0 !important; height: 1em !important; }
table.progress td.todo  { background: var(--c-border) !important; }
table.progress td.done  { background: var(--c-success) !important; opacity: .5 !important; }
table.progress td.closed { background: var(--c-success) !important; }
p.percent { font-size: 86% !important; margin: 0 !important; }
.progress-bar { height: 8px !important; border-radius: 4px !important; overflow: hidden !important; }
.progress-bar-done { background: var(--c-primary) !important; border-radius: 4px !important; transition: width var(--t-slow) !important; }
.progress-bar-todo { background: var(--c-border) !important; }

/* ── 22. DARK MODE TOGGLE (injected) ─────────────────────── */
#rm-darkmode-toggle {
  position: fixed !important;
  bottom: var(--sp-6) !important;
  right: var(--sp-6) !important;
  width: 44px !important;
  height: 44px !important;
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  z-index: 9999 !important;
  box-shadow: var(--shadow-md) !important;
  font-size: 18px !important;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast) !important;
  padding: 0 !important;
  line-height: 1 !important;
  color: var(--c-text) !important;
}

#rm-darkmode-toggle:hover {
  transform: scale(1.1) !important;
  box-shadow: var(--shadow-lg) !important;
  background: var(--c-primary) !important;
  color: var(--c-on-primary) !important;
  border-color: var(--c-primary) !important;
}

/* ── 23. TOAST NOTIFICATIONS ─────────────────────────────── */
#rm-toast-container {
  position: fixed !important;
  bottom: var(--sp-8) !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  display: flex !important;
  flex-direction: column-reverse !important;
  gap: var(--sp-2) !important;
  z-index: 9998 !important;
  pointer-events: none !important;
  min-width: 280px !important;
  max-width: 420px !important;
}

.rm-toast {
  background: var(--c-surface) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r-md) !important;
  padding: var(--sp-3) var(--sp-4) !important;
  box-shadow: var(--shadow-lg) !important;
  font-size: var(--text-sm) !important;
  color: var(--c-text) !important;
  pointer-events: auto !important;
  display: flex !important;
  align-items: flex-start !important;
  gap: var(--sp-3) !important;
  animation: rm-slide-in var(--t) forwards !important;
  line-height: 1.5 !important;
}

.rm-toast.rm-toast-out { animation: rm-slide-out var(--t) forwards !important; }
.rm-toast-icon { font-size: 15px !important; flex-shrink: 0 !important; margin-top: .1rem !important; }
.rm-toast-success .rm-toast-icon { color: var(--c-success) !important; }
.rm-toast-error   .rm-toast-icon { color: var(--c-danger)  !important; }
.rm-toast-warning .rm-toast-icon { color: var(--c-warning) !important; }
.rm-toast-info    .rm-toast-icon { color: var(--c-info)    !important; }

@keyframes rm-slide-in {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}
@keyframes rm-slide-out {
  from { opacity: 1; transform: translateY(0)    scale(1);   }
  to   { opacity: 0; transform: translateY(10px) scale(.96); }
}

/* ── 24. COLLAPSIBLE SECTIONS ────────────────────────────── */
.rm-collapsible-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid var(--c-border) !important;
  border-radius: 0 !important;
  font: inherit !important;
  color: inherit !important;
  text-align: inherit !important;
  cursor: pointer !important;
  user-select: none !important;
  padding: var(--sp-3) 0 !important;
  margin-bottom: var(--sp-3) !important;
  transition: color var(--t-fast) !important;
}

.rm-collapsible-header:hover { color: var(--c-primary) !important; }
.rm-collapsible-header:focus-visible {
  outline: 2px solid var(--c-primary) !important;
  outline-offset: 2px !important;
}

.rm-collapsible-toggle {
  font-size: 11px !important;
  color: var(--c-text-subtle) !important;
  transition: transform var(--t) !important;
  display: inline-block !important;
}

.rm-collapsible-header.is-collapsed .rm-collapsible-toggle { transform: rotate(-90deg) !important; }

.rm-collapsible-body {
  overflow: hidden !important;
  transition: max-height var(--t-slow) ease, opacity var(--t) !important;
  max-height: 5000px !important;
  opacity: 1 !important;
}

.rm-collapsible-body.is-collapsed { max-height: 0 !important; opacity: 0 !important; }

/* ── 25. TABS (settings, project settings, user tabs) ──────── */
/* Exclude .jstTabs (Edit/Preview wiki toolbar — keeps its own style) */
.tabs:not(.jstTabs) {
  overflow: visible !important;
  height: auto !important;
}
/* Allow #content to expand vertically when tabs wrap */
#content { overflow: visible !important; }
.tabs:not(.jstTabs) > ul {
  display: flex !important;
  flex-wrap: wrap !important;
  width: 100% !important;
  min-width: 0 !important;
  gap: 2px var(--sp-1) !important;
  border-bottom: 2px solid var(--c-border) !important;
  list-style: none !important;
  margin: 0 0 var(--sp-5) !important;
  padding: 0 !important;
  position: static !important;
}
.tabs:not(.jstTabs) > ul li { margin: 0 !important; }
.tabs:not(.jstTabs) > ul li a {
  display: block !important;
  padding: var(--sp-2) var(--sp-3) !important;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  color: var(--c-text-muted) !important;
  text-decoration: none !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  background: none !important;
  box-shadow: none !important;
  margin-bottom: -2px !important;
  border-radius: 0 !important;
  white-space: nowrap !important;
  transition: color var(--t-fast), border-color var(--t-fast) !important;
}
.tabs:not(.jstTabs) > ul li a:hover { color: var(--c-text) !important; border-bottom-color: var(--c-border) !important; }
.tabs:not(.jstTabs) > ul li a.selected { color: var(--c-primary) !important; border-bottom-color: var(--c-primary) !important; font-weight: 600 !important; }
/* Hide Redmine's overflow scroll buttons — we wrap instead */
.tabs-buttons { display: none !important; }

/* ── 26. TABULAR FORMS (settings, user edit, project settings) ── */
.tabular p {
  display: grid !important;
  grid-template-columns: 220px 1fr auto !important;
  align-items: baseline !important;
  gap: var(--sp-1) var(--sp-4) !important;
  padding: var(--sp-2) 0 !important;
  border-bottom: 1px solid var(--c-border) !important;
  margin: 0 !important;
}
.tabular p:last-of-type { border-bottom: none !important; }
/* Status with both the help (i) and the transition warning: the third column holds one
   icon, so the warning wrapped under the label. A fourth column for the second one. */
@media (min-width: 900px) {
  .tabular p:has(> select + .icon-only + .icon-only) { grid-template-columns: 220px 1fr auto auto !important; }
}
.tabular p em.info, .tabular p span.description, .tabular p .description {
  grid-column: 2 !important;
  font-size: var(--text-xs) !important;
  color: var(--c-text-subtle) !important;
  font-style: normal !important;
  margin-top: 2px !important;
}
.tabular label {
  width: 100% !important;
  margin-left: 0 !important;
  text-align: right !important;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  color: var(--c-text-muted) !important;
  line-height: 1.5 !important;
  padding-right: var(--sp-1) !important;
}
/* Checkboxes and radios keep their own size, at the left. Core's responsive.css gives
   every .tabular input width: 100% on phones (it exempts checkboxes, not radios), and a
   checkbox that is itself a grid item in .tabular p is stretched across the column on
   every width — either way the box or circle was drawn in the middle of a wide input,
   with its text pushed out of the custom-field radio group (QA required). */
.tabular input[type=checkbox],
.tabular input[type=radio] {
  width: auto !important;
  justify-self: start !important;
}
/* Bare checkbox/radio labels (inside <p>, not .floating/.block) — left-align,
   shrink to content. Excluding .floating/.block so their explicit rules below
   win the width war (otherwise :has() specificity 0,3,1 beats 0,2,1). */
.tabular label:not(.floating):not(.block):has(input[type=checkbox]),
.tabular label:not(.floating):not(.block):has(input[type=radio]) {
  text-align: left !important;
  width: auto !important;
  padding-right: 0 !important;
  font-weight: normal !important;
}
/* Project modules + role permissions use <label class="floating"> for a
   horizontal checkbox grid. Restore Redmine's fixed-width inline-block
   layout so they don't stack one-per-row under our width:100% reset. */
.tabular label.floating {
  display: inline-block !important;
  width: 270px !important;
  margin-left: 0 !important;
  padding-right: 0 !important;
  text-align: left !important;
  font-weight: normal !important;
  vertical-align: top !important;
  float: none !important;
}
/* <label class="block"> (e.g. role member-management radio choices) — one per row */
.tabular label.block {
  display: block !important;
  width: auto !important;
  margin-left: 0 !important;
  padding-right: 0 !important;
  text-align: left !important;
  font-weight: normal !important;
  float: none !important;
}
.tabular input[type=text],
.tabular input[type=email],
.tabular input[type=password],
.tabular input[type=number],
.tabular input[type=url],
.tabular select {
  width: auto !important;
  min-width: 200px !important;
  max-width: 480px !important;
}
.tabular textarea { max-width: 600px !important; width: 100% !important; }
/* Wiki editors in forms (issue description, notes, wiki, news) take the full row: the
   600px cap above is for plain textareas, a description needs the room */
.tabular textarea.wiki-edit { max-width: none !important; }
/* Time entry form: the date is not in the 480px-capped list above, so it stretched across
   the whole row while the comment (up to 1024 characters) stayed at 480px. The other way
   round makes sense. Mobile keeps its full-width stacked fields. */
@media (min-width: 900px) {
  .controller-timelog .tabular input#time_entry_spent_on { width: 180px !important; justify-self: start !important; }
  .controller-timelog .tabular input#time_entry_comments { width: 100% !important; max-width: none !important; }
}
/* RedmineUP Checklists: the new-item field is "width: 40%", which .tabular input[type=text]
   { width: auto } above turned into ~170px */
.tabular span.checklist-edit-box input,
span.checklist-edit-box input[type=text] { width: min(640px, 100%) !important; max-width: 100% !important; }
/* View Customize plugin: table cells set their own colour, so its tr.disable grey never
   showed; the code box on the rule page is hard-coded #fafafa, under light text in dark mode */
table.list.view_customize tbody tr.disable td,
table.list.view_customize tbody tr.disable td a { color: var(--c-text-subtle) !important; }
table.view_customize.box td pre {
  background: var(--c-surface-2) !important;
  border-color: var(--c-border) !important;
  color: var(--c-text) !important;
}
table.view_customize.box td pre code { background: none !important; border: none !important; padding: 0 !important; }
textarea#view_customize_code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; }
.tabular .description,
.tabular em { font-size: var(--text-xs) !important; color: var(--c-text-subtle) !important; }

/* ── 27. MISC ────────────────────────────────────────────── */
hr { border: none !important; border-top: 1px solid var(--c-border) !important; margin: var(--sp-4) 0 !important; }

.flyout-menu { display: none !important; }

#footer {
  text-align: center !important;
  padding: var(--sp-4) var(--sp-6) !important;
  font-size: var(--text-xs) !important;
  color: var(--c-text-subtle) !important;
  border-top: 1px solid var(--c-border) !important;
  background: var(--c-surface) !important;
  margin-top: var(--sp-8) !important;
}

#footer a { color: var(--c-text-muted) !important; }

#ajax-indicator {
  position: fixed !important;
  top: var(--topbar-h) !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  background: var(--c-primary) !important;
  color: var(--c-on-primary) !important;
  padding: var(--sp-2) var(--sp-4) !important;
  border-radius: 0 0 var(--r) var(--r) !important;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  z-index: 9999 !important;
  box-shadow: var(--shadow-md) !important;
}

.next-prev-links { font-size: var(--text-xs) !important; color: var(--c-text-subtle) !important; }
h2 { font-size: var(--text-xl) !important; font-weight: 700 !important; color: var(--c-text) !important; margin: 0 0 var(--sp-4) !important; }
h3 { font-size: var(--text-base) !important; font-weight: 600 !important; color: var(--c-text) !important; }

/* ── 26. RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 899px) {
  /* Sidebar — slides in from left as overlay */
  #sidebar {
    display: block !important;
    position: fixed !important;
    top: 44px !important;
    left: 0 !important;
    height: calc(100vh - 44px) !important;
    z-index: 1049 !important;
    transform: translateX(-100%) !important;
    transition: transform var(--t) !important;
    box-shadow: var(--shadow-lg) !important;
    width: var(--sidebar-w) !important;
    min-width: var(--sidebar-w) !important;
    overflow-y: auto !important;
    opacity: 1 !important;
  }
  body.sidebar-open #sidebar { transform: translateX(0) !important; }
  /* Redmine puts sidebar content in flyout on mobile — mirror it back to our sidebar */
  .flyout-menu { display: none !important; }

  /* Main content fills full width when sidebar is off-screen */
  #main { flex-direction: column !important; }
  #content {
    padding: var(--sp-3) !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Show hamburger button on mobile */
  #rm-hamburger { display: flex !important; }

  /* Topbar — hamburger layout on mobile */
  #top-menu {
    position: static !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 var(--sp-2) !important;
    height: 44px !important;
    min-height: 44px !important;
    overflow: visible !important;
  }
  /* Hide all top-menu children except the hamburger button */
  #top-menu > ul,
  #top-menu #account,
  #top-menu #loggedas {
    display: none !important;
  }
  /* Dropdown panel — shown when nav-open */
  body.nav-open #top-menu > ul,
  body.nav-open #top-menu #account,
  body.nav-open #top-menu #loggedas {
    display: block !important;
    position: absolute !important;
    top: 44px !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    background: var(--c-topbar-bg) !important;
    z-index: 1060 !important;
    box-shadow: 0 4px 12px rgb(0 0 0 / .3) !important;
    padding: 0 !important;
    animation: navSlideDown .15s ease both !important;
  }
  /* Stack the three panels vertically */
  body.nav-open #top-menu > ul    { top: 44px !important; }
  body.nav-open #top-menu #account { top: 44px !important; border-top: 1px solid rgb(255 255 255 / .1) !important; }
  body.nav-open #top-menu #loggedas { top: 44px !important; }
  /* Actually use a wrapper approach via flex column on top-menu when open */
  body.nav-open #top-menu {
    flex-wrap: wrap !important;
    height: auto !important;
    align-items: flex-start !important;
  }
  body.nav-open #top-menu > ul,
  body.nav-open #top-menu #account,
  body.nav-open #top-menu #loggedas {
    position: static !important;
    width: 100% !important;
    box-shadow: none !important;
  }
  /* Dropdown wrapper gets the shadow */
  body.nav-open #top-menu {
    box-shadow: 0 6px 16px rgb(0 0 0 / .35) !important;
  }
  #top-menu ul li { width: 100% !important; }
  #top-menu li a {
    display: block !important;
    padding: var(--sp-2) var(--sp-4) !important;
    font-size: var(--text-sm) !important;
    border-radius: 0 !important;
  }
  #top-menu li a:hover { background: rgb(255 255 255 / .08) !important; }
  #top-menu #loggedas {
    padding: var(--sp-2) var(--sp-4) !important;
    font-size: var(--text-xs) !important;
    opacity: .7 !important;
    border-top: 1px solid rgb(255 255 255 / .1) !important;
  }
  #top-menu #account ul { padding: var(--sp-1) 0 !important; }
  #top-menu #account li a { padding: var(--sp-2) var(--sp-4) !important; }

  /* Keep #header visible so its #main-menu child can render, but hide
     the heavy bits (h1/title, quick-search) — they'd take too much room
     on narrow viewports. Users still see project context via the sticky
     issue header when drilling into an issue. */
  #header {
    display: block !important;
    position: static !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border-bottom: none !important;
  }
  #header h1,
  #header h1:has(.current-project),
  #header #quick-search,
  #header #project-jump { display: none !important; }

  /* Remove JS-calculated top margin/padding — not needed when header scrolls */
  #main { margin-top: 0 !important; padding-top: 0 !important; }
  #rm-sidebar-toggle { position: fixed !important; }

  /* Redmine's responsive.css offsets sticky-issue-header by 64px for its own flyout.
     Our theme doesn't use that flyout, so reset to 0. */
  div#sticky-issue-header { top: 0 !important; }
}

/* Sticky issue header (JS-inserted when scrolling past the original H1):
   takes over the topbar position — same height, same dark navy — so the
   user always sees "what issue am I on" in the same strip. */
div#sticky-issue-header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: var(--topbar-h) !important;
  padding: 0 var(--sp-4) !important;
  display: flex !important;
  align-items: center !important;
  gap: var(--sp-3) !important;
  background: var(--c-topbar-bg) !important;
  color: var(--c-topbar-text) !important;
  border-bottom: none !important;
  box-shadow: 0 1px 3px rgb(0 0 0 / .4) !important;
  z-index: 1001 !important;              /* above #top-menu (1000) */
  font-family: var(--font-sans) !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  transform: translateY(-100%) !important;
  transition: transform var(--t) ease !important;
}
div#sticky-issue-header.is-visible {
  transform: translateY(0) !important;
}
div#sticky-issue-header .issue-heading {
  font-size: var(--text-sm) !important;
  font-weight: 600 !important;
  color: rgba(255, 255, 255, .7) !important;
  letter-spacing: .02em !important;
  flex-shrink: 0 !important;
}
div#sticky-issue-header .subject {
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  color: white !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
}

@media (max-width: 899px) {
  /* keep the mobile override explicit */
  /* placeholder to preserve CSS block structure */

  /* Nav tabs — static on mobile, scroll horizontally.
     Match Redmine's `#header #main-menu { display: none }` specificity
     (0,2,0) so we re-show it here. */
  #header #main-menu,
  #main-menu {
    display: block !important;
    position: static !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    background: var(--c-header-bg) !important;
    border-top: 1px solid var(--c-border) !important;
  }
  #main-menu::-webkit-scrollbar { display: none !important; }
  #main-menu ul {
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    width: max-content !important;
  }
  #main-menu li a { padding: var(--sp-2) var(--sp-3) !important; font-size: var(--text-sm) !important; }

  /* New-object + button */
  #main-menu a#new-object {
    width: 32px !important;
    height: 32px !important;
    font-size: 24px !important;
    flex-shrink: 0 !important;
  }

  /* Sidebar toggle — a round floating button bottom-left, the pair of the dark-mode
     toggle bottom-right. As a tab on the left edge under the menu it covered the
     page's first button (New issue, Edit). Above the open overlay (1049) so the same
     button closes it. */
  #rm-sidebar-toggle,
  body.sidebar-collapsed #rm-sidebar-toggle {
    top: auto !important;
    bottom: var(--sp-6) !important;
    left: var(--sp-6) !important;
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    border: 1px solid var(--c-border) !important;
    border-radius: 50% !important;
    box-shadow: var(--shadow-md) !important;
    font-size: 22px !important;
    line-height: 1 !important;
    color: var(--c-text) !important;
    z-index: 1050 !important;
  }

  /* Overview two-column → single column */
  .splitcontent { flex-direction: column !important; }
  .splitcontentleft,
  .splitcontentright { margin: 0 0 var(--sp-3) 0 !important; width: 100% !important; }

  /* Tables — allow horizontal scroll */
  .autoscroll { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }

  /* Contextual actions — wrap */
  .contextual { flex-wrap: wrap !important; gap: var(--sp-2) !important; }

  /* Issue attributes grid — single column */
  .attributes table td { display: block !important; width: 100% !important; }

  /* Tabular forms — stack label above input so narrow viewports don't
     get forced into a 220px label column that overflows right. */
  .tabular p {
    grid-template-columns: 1fr !important;
    row-gap: var(--sp-1) !important;
    padding: var(--sp-3) 0 !important;
  }
  /* A select followed by a small control — status/tracker help (i), transition warning,
     New category/version +, Assign to me — got a line of its own in the one column.
     Keep it beside the select; the label stays above. */
  .tabular p:has(> select + :is(a.icon-only, span.icon-only, a.assign-to-me-link)) {
    grid-auto-columns: auto !important;
    column-gap: var(--sp-2) !important;
    align-items: center !important;
  }
  .tabular p:has(> select + :is(a.icon-only, span.icon-only, a.assign-to-me-link)) > select { grid-row: 2 !important; grid-column: 1 !important; }
  .tabular p:has(> select + :is(a.icon-only, span.icon-only, a.assign-to-me-link)) > :is(a.icon-only, span.icon-only, a.assign-to-me-link) {
    grid-row: 2 !important;
    white-space: nowrap !important;
  }
  /* Estimated time: "Hours" is a bare text node after the input, so it can only be
     placed by the columns: label across, then input and text side by side. */
  .tabular p:has(> #issue_estimated_hours),
  .tabular p:has(> #time_entry_hours) {
    grid-template-columns: minmax(0, 1fr) auto !important;
    column-gap: var(--sp-2) !important;
    align-items: center !important;
  }
  /* RedmineUP Checklists: the new-item field fills the line, so its + (save) wrapped
     under it. Field and + share the line; the field shrinks. */
  #checklist_form_items .checklist-item.new {
    display: flex !important;
    align-items: center !important;
    gap: var(--sp-2) !important;
  }
  #checklist_form_items .checklist-item.new .checklist-edit-box { flex: 1 1 auto !important; min-width: 0 !important; }
  #checklist_form_items .checklist-item.new .checklist-edit-box input[type=text] { width: 100% !important; }
  #checklist_form_items .checklist-item.new .save-new-by-button { flex: none !important; }
  .tabular p:has(> #issue_estimated_hours) > label,
  .tabular p:has(> #time_entry_hours) > label { grid-column: 1 / -1 !important; }
  .tabular label {
    text-align: left !important;
    padding-right: 0 !important;
    color: var(--c-text-subtle) !important;
    font-weight: 500 !important;
  }
  .tabular input[type=text],
  .tabular input[type=email],
  .tabular input[type=password],
  .tabular input[type=number],
  .tabular input[type=url],
  .tabular select,
  form select,
  form input[type=text] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  /* Filter rows: the value cell is only as wide as its content, so the select's
     width: 100% above left no room for the multi-select "+" (.toggle-multiselect)
     and it wrapped under the select. Keep them on one line; the select shrinks if
     it must. :not([style*=none]) leaves jQuery's hidden spans hidden. */
  #filters-table .values > span:not([style*="none"]) {
    display: inline-flex !important;
    align-items: center !important;
    gap: var(--sp-1) !important;
    max-width: 100% !important;
  }
  #filters-table .values select {
    width: auto !important;
    flex: 0 1 auto !important;
    min-width: 0 !important;
  }
  #filters-table .values .toggle-multiselect { flex: none !important; margin-right: 0 !important; }

  /* Attachments (issue, wiki, news…): four table cells side by side squeezed name, size,
     author and date into ~80px columns. One block per file instead: name, size and
     download on the first line with delete at the right, description and author/date
     below at full width. */
  div.attachments > .contextual {
    float: none !important;
    display: flex !important;
    justify-content: flex-end !important;
    margin: 0 !important;
  }
  div.attachments table,
  div.attachments tbody { display: block !important; width: 100% !important; }
  div.attachments tr {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    column-gap: var(--sp-2) !important;
    align-items: start !important;
    padding: var(--sp-2) 0 !important;
    border-bottom: 1px solid var(--c-border) !important;
  }
  div.attachments tr:last-child { border-bottom: none !important; }
  div.attachments td { display: block !important; width: auto !important; padding: 0 !important; }
  div.attachments td:nth-child(1) { grid-column: 1 !important; grid-row: 1 !important; overflow-wrap: anywhere !important; }
  div.attachments td:nth-child(4) { grid-column: 2 !important; grid-row: 1 !important; }
  div.attachments td:nth-child(2) { grid-column: 1 / -1 !important; grid-row: 2 !important; }
  div.attachments td:nth-child(3) { grid-column: 1 / -1 !important; grid-row: 3 !important; }
  div.attachments td:empty { display: none !important; }

  /* Issue page: the floated « Previous | 5 of 6 | Next » took ~195px of a ~316px card
     and squeezed the subject into a narrow column beside it. Own row, centred, above
     the avatar; the subject then wraps beside the avatar and under it. */
  div.issue.details > .next-prev-links {
    float: none !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    gap: 0 var(--sp-2) !important;
    width: 100% !important;
    margin: 0 0 var(--sp-3) !important;
  }
  /* Attribute cards: core gives the label a fixed 170px (+10px gap), which left ~100px
     for the value, so names and dates broke over two or three lines. 2 : 3 instead. */
  div.issue .attributes .attribute {
    display: grid !important;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) !important;
    column-gap: var(--sp-2) !important;
    padding-left: 0 !important;
  }
  div.issue .attributes .attribute .label {
    float: none !important;
    width: auto !important;
    margin-left: 0 !important;
    overflow-wrap: anywhere !important;
  }

  /* Larger tap targets for icon-only buttons (36x36 hits 32px min) */
  a.icon-only,
  #sidebar a.icon-only,
  #sidebar ul li a.icon-only,
  #content a.icon-only {
    width: 36px !important;
    height: 36px !important;
  }
  a.icon-only .icon-svg,
  a.icon-only > svg,
  #sidebar a.icon-only .icon-svg,
  #sidebar a.icon-only > svg {
    width: 18px !important;
    height: 18px !important;
  }

  /* JSToolbar — let buttons wrap instead of overflowing right.
     Redmine's jstoolbar sets display:inline-block + white-space:nowrap on
     <li class="tab-elements"> which forces a single-line toolbar. Flip the
     chain so buttons wrap into multiple rows on mobile. */
  .jstBlock .jstTabs.tabs ul {
    min-width: 0 !important;
    max-width: 100% !important;
  }
  .jstBlock .jstTabs.tabs li.tab-elements {
    max-width: 100% !important;
    white-space: normal !important;
  }
  .jstElements {
    display: flex !important;
    flex-wrap: wrap !important;
    white-space: normal !important;
    max-width: 100% !important;
  }
  .jstElements button {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
  }

  /* JSToolbar tabs (Edit / Preview) — taller for tap */
  .jstTabs a.tab-edit,
  .jstTabs a.tab-preview {
    min-height: 40px !important;
    padding: var(--sp-2) var(--sp-3) !important;
  }

  /* Issue attributes word-wrap so long text doesn't push table wider */
  .attributes table td { word-break: break-word !important; overflow-wrap: break-word !important; }

  /* Sticky issue header — tighter padding + smaller text on narrow screens */
  div#sticky-issue-header {
    padding: 0 var(--sp-2) !important;
    gap: var(--sp-2) !important;
  }
  div#sticky-issue-header .issue-heading,
  div#sticky-issue-header .subject {
    font-size: var(--text-xs) !important;
  }

  /* Toast container — full width minus small margin */
  #rm-toast-container {
    left: var(--sp-3) !important;
    right: var(--sp-3) !important;
    width: auto !important;
    max-width: none !important;
  }

  /* Forms/box containers — reduce internal padding on small screens */
  .box, fieldset.box {
    padding: var(--sp-3) !important;
  }

  /* Contextual bar — stack on very narrow widths; buttons fill row */
  .contextual a.icon, .contextual a.icon.icon-add {
    padding: var(--sp-2) var(--sp-3) !important;
    min-height: 36px !important;
  }

  /* Issue history entries — reduce left indent so content has room */
  #history .journal { padding: var(--sp-3) !important; }

  /* Journal header (avatar + "Updated by X N days ago" + action icons).
     On desktop it's flex with info left + meta right. On narrow viewports
     meta steals horizontal space and the info text wraps into a stack.
     Stack them vertically so both get full width. */
  .journal-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: var(--sp-2) !important;
  }
  .journal-info { flex: 1 1 auto !important; min-width: 0 !important; }
  .journal-meta {
    align-self: flex-end !important;
    flex: 0 0 auto !important;
  }
  .journal-actions { flex-wrap: wrap !important; }

  /* History/Notes tabs wrap to multiple rows on narrow screens — keep
     them tight with smaller padding and no extra gaps. */
  #history > .tabs ul,
  #history .tabs ul {
    gap: 0 !important;
  }
  #history .tabs li a {
    padding: var(--sp-2) var(--sp-3) !important;
    font-size: var(--text-sm) !important;
  }

  /* File attachment links: bigger tap area */
  a.icon.icon-attachment { padding: var(--sp-1) 0 !important; min-height: 32px !important; display: inline-flex !important; align-items: center !important; }
}

/* ── DARK MODE: override Redmine's hardcoded white backgrounds ── */

/* Body & wrapper */
html.dark-mode body,
html.dark-mode #wrapper { background: var(--c-bg) !important; color: var(--c-text) !important; }

/* Header & topbar */
html.dark-mode #header { background: var(--c-header-bg) !important; }
html.dark-mode #header h1,
html.dark-mode #header h1 a { color: var(--c-text) !important; }
html.dark-mode #main-menu { background: var(--c-header-bg) !important; border-top-color: var(--c-border) !important; }

/* Content area */
html.dark-mode #content { background: transparent !important; }
html.dark-mode #sidebar  { background: var(--c-sidebar-bg) !important; border-right-color: var(--c-border) !important; }

/* Generic white boxes — Redmine uses .box, .splitcontentleft/right, fieldset etc. */
html.dark-mode .box,
html.dark-mode fieldset,
html.dark-mode .splitcontentleft,
html.dark-mode .splitcontentright,
html.dark-mode .tabular,
html.dark-mode #query_form_with_buttons,
html.dark-mode .query-totals { background: var(--c-surface) !important; color: var(--c-text) !important; border-color: var(--c-border) !important; }

/* Project list cards */
html.dark-mode ul.projects li div.root,
html.dark-mode ul.projects li div.child,
html.dark-mode ul.projects li div.leaf { background: var(--c-surface) !important; border-color: var(--c-border) !important; color: var(--c-text) !important; }

/* Tables */
html.dark-mode table,
html.dark-mode table.list,
html.dark-mode table.list thead,
html.dark-mode table.list tbody tr.odd,
html.dark-mode table.list tbody tr.even { background: var(--c-surface) !important; color: var(--c-text) !important; }
html.dark-mode table.list tbody tr.even { background: var(--c-surface-2) !important; }
html.dark-mode table.list thead { background: var(--c-surface-2) !important; }
html.dark-mode table td,
html.dark-mode table th { border-color: var(--c-border) !important; color: var(--c-text) !important; }

/* Autoscroll wrapper */
html.dark-mode .autoscroll { background: var(--c-surface) !important; border-color: var(--c-border) !important; }

/* Issue details card */
html.dark-mode .issue.details { background: var(--c-surface) !important; border-color: var(--c-border) !important; }

/* History / journals */
html.dark-mode #history { background: var(--c-surface) !important; border-color: var(--c-border) !important; }
html.dark-mode .journal:hover { background: var(--c-surface-2) !important; }

/* Subtasks / relations */
html.dark-mode #issue_tree,
html.dark-mode #relations { background: var(--c-surface) !important; border-color: var(--c-border) !important; }

/* Form inputs */
html.dark-mode input[type=text],
html.dark-mode input[type=email],
html.dark-mode input[type=password],
html.dark-mode input[type=number],
html.dark-mode input[type=search],
html.dark-mode input[type=url],
html.dark-mode input[type=date],
html.dark-mode select,
html.dark-mode textarea,
html.dark-mode .check_box_group { background-color: var(--c-surface-2) !important; color: var(--c-text) !important; border-color: var(--c-border) !important; }
/* The date picker's calendar icon is drawn by the browser: tell it the field is dark */
html.dark-mode input[type=date] { color-scheme: dark; }

/* Query form */
html.dark-mode #query_form { background: var(--c-surface) !important; border-color: var(--c-border) !important; }
html.dark-mode #filters-table { background: transparent !important; color: var(--c-text) !important; }

/* Core hardcodes legend text and the sprite_icon() SVG stroke to fixed dark grays
   (--oc-gray-9/--oc-gray-8) meant for light backgrounds only - illegible in dark mode. Most
   visible on the "Filters"/"Options" collapsible fieldset headers. The icon rule is scoped to
   legends: a site-wide svg.icon-svg rule also greyed the accent-coloured icons on the issue
   page (Edit / Log time / Watch / Copy, reactions). */
html.dark-mode legend {
  color: var(--c-text-muted) !important;
}
html.dark-mode legend svg.icon-svg {
  stroke: var(--c-text-muted) !important;
}

/* Dropdowns / context menu */
html.dark-mode .drdn-content {
  background: var(--c-surface) !important;
  background-color: var(--c-surface) !important;
  border-color: var(--c-border) !important;
  color: var(--c-text) !important;
}
html.dark-mode .drdn-items > * {
  color: var(--c-text) !important;
  border-color: var(--c-surface) !important; /* override hardcoded white item-borders */
}
html.dark-mode .drdn-items > a { color: var(--c-text) !important; }
html.dark-mode .drdn-items > a:hover {
  background: var(--c-primary-light) !important;
  color: var(--c-primary) !important;
}
html.dark-mode .drdn-items > span { color: var(--c-text-muted) !important; }
html.dark-mode div + .drdn-items { border-top-color: var(--c-border) !important; }
html.dark-mode #context-menu { background: var(--c-surface) !important; border-color: var(--c-border) !important; }

/* Sidebar toggle button */
html.dark-mode #rm-sidebar-toggle { background: var(--c-surface) !important; border-color: var(--c-border) !important; color: var(--c-text-subtle) !important; }

/* Wiki / descriptions */
html.dark-mode .wiki { color: var(--c-text) !important; }
html.dark-mode .wiki code, html.dark-mode code { background: var(--c-surface-2) !important; color: var(--c-text) !important; border-color: var(--c-border) !important; }
html.dark-mode .wiki pre { background: var(--c-surface-2) !important; border-color: var(--c-border) !important; }

/* Pagination */
html.dark-mode .pagination a,
html.dark-mode .pagination span.current { background: var(--c-surface) !important; border-color: var(--c-border) !important; color: var(--c-text-muted) !important; }
html.dark-mode .pagination span.current { background: var(--c-primary) !important; color: var(--c-on-primary) !important; }
/* Core puts a light #ddd border on each ul.pages li (around the theme's own link chip) and
   paints the current page #628DB6 — schemes remap both, plain dark mode never did */
html.dark-mode .pagination ul.pages li { border-color: var(--c-border) !important; }
html.dark-mode .pagination ul.pages li.current {
  background-color: var(--c-primary) !important;
  border-color: var(--c-primary) !important;
  color: var(--c-on-primary) !important;
}

/* Flash messages — text color is driven by --c-flash-*-text tokens, redefined in html.dark-mode */

/* Footer */
html.dark-mode #footer { background: var(--c-surface) !important; border-top-color: var(--c-border) !important; }

/* Misc links & text — var(--c-primary) / var(--c-primary-hover) redefine in dark-mode block */
html.dark-mode h2, html.dark-mode h3 { color: var(--c-text) !important; }
/* Core: #content h1…h6 { color: #555 } — the wiki h1 read at 2.2:1 */
html.dark-mode #content h1, html.dark-mode #content h4,
html.dark-mode #content h5, html.dark-mode #content h6 { color: var(--c-text) !important; }
/* Core secondary text (#555 / #666 / #888 / #959595) is fine on white, ~2.2–2.9:1 on dark */
html.dark-mode div#activity dt .time,
html.dark-mode div#activity dd span.description,
html.dark-mode #search-results dd span.description,
html.dark-mode p.other-formats,
html.dark-mode .wiki-update-info,
html.dark-mode span.pagination,
html.dark-mode em.info,
html.dark-mode div.attachments span.author,
html.dark-mode ul.revision-info { color: var(--c-text-muted) !important; }
/* Core #959595 is 3.0:1 even on white */
.journals .journal-details { color: var(--c-text-muted) !important; }
/* Core paints the selected sidebar link #9DB9D5 (2.7:1 with muted text); dark mode
   and schemes already re-colour it, light Modern gets the theme's active style */
#sidebar a.selected { background-color: var(--c-primary-light) !important; color: var(--c-primary) !important; }
#sidebar a.selected svg.icon-svg { stroke: var(--c-primary) !important; }
html.dark-mode .badge-status-open { color: var(--c-primary) !important; border-color: var(--c-primary) !important; }

/* Sidebar selected query link — overrides hardcoded #9DB9D5 */
html.dark-mode #sidebar a.selected {
  background-color: var(--c-primary) !important;
  color: var(--c-on-primary) !important;
}
html.dark-mode #sidebar a.selected svg.icon-svg { stroke: var(--c-on-primary) !important; }

/* Wiki toolbar buttons — overrides jstoolbar.css hardcoded #f7f7f7 */
html.dark-mode .jstElements button {
  background-color: var(--c-surface-2) !important;
  border-color: var(--c-border) !important;
  color: var(--c-text) !important;
}
html.dark-mode .jstElements button:hover {
  background-color: var(--c-border) !important;
  border-color: var(--c-border-2) !important;
}
/* "pre" text label on the pre button */
html.dark-mode .jstb_pre::before { color: var(--c-text-muted) !important; }

/* Wiki editor (Edit / Preview + toolbar over the textarea). Core overlaps this row
   1px onto the textarea (margin-bottom: -1px) so the selected tab joins the field —
   which makes the field's focus ring and the row share pixels. Left to paint order,
   the buttons covered the ring and it showed only between them, as dashes.
   The layering is explicit instead:
   - the textarea (z 1) sits under the row (z 2); the row itself is transparent, so
     the ring shows through everywhere except under the tabs;
   - the selected tab has the field's colour, bottom border included, so it covers
     the ring exactly where tab and field join;
   - the toolbar buttons sit 4px above the edge (core: 2px), out of reach of the
     2px ring, so it never touches the icons. */
#content .jstTabs.tabs { position: relative !important; z-index: 2 !important; }
.jstEditor textarea { position: relative; z-index: 1; }
.jstTabs .jstElements { height: auto !important; padding-bottom: 4px !important; }  /* core: fixed 26px, border-box would eat the padding */
.jstEditor textarea:focus,
.jstEditor textarea:focus-visible {
  outline: none !important;
  box-shadow: 0 0 0 2px var(--c-primary-ring) !important;
}
#content .jstTabs.tabs li a { border-radius: var(--r-sm) var(--r-sm) 0 0 !important; }
#content .jstTabs.tabs li a.selected { border-bottom-color: var(--c-surface) !important; }
html.dark-mode #content .jstTabs.tabs li a.selected { border-bottom-color: var(--c-surface-2) !important; }

/* Dark mode: core toolbar icons are dark SVG backgrounds — invisible on the dark
   button. The button hides its own image and ::after redraws it inverted, so the
   button keeps its themed background and border. Plugin buttons (DMSF, macros…)
   bring their own icons and are left alone; .jstb_pre is a text label. */
html.dark-mode .jstElements :is(.jstb_strong, .jstb_em, .jstb_ins, .jstb_del, .jstb_code,
  .jstb_h1, .jstb_h2, .jstb_h3, .jstb_ul, .jstb_ol, .jstb_tl, .jstb_bq, .jstb_unbq,
  .jstb_table, .jstb_precode, .jstb_link, .jstb_img, .jstb_help) {
  position: relative !important;
  background-size: 0 0 !important;
}
html.dark-mode .jstElements :is(.jstb_strong, .jstb_em, .jstb_ins, .jstb_del, .jstb_code,
  .jstb_h1, .jstb_h2, .jstb_h3, .jstb_ul, .jstb_ol, .jstb_tl, .jstb_bq, .jstb_unbq,
  .jstb_table, .jstb_precode, .jstb_link, .jstb_img, .jstb_help)::after {
  content: '' !important;
  position: absolute !important;
  inset: 0 !important;
  background-image: inherit !important;
  background-repeat: no-repeat !important;
  background-position: 50% 50% !important;
  filter: invert(1) !important;
  opacity: .85 !important;
  pointer-events: none !important;
}

/* Wiki preview area — overrides hardcoded #ffffff */
html.dark-mode .wiki-preview {
  background-color: var(--c-surface-2) !important;
  border-color: var(--c-border) !important;
  color: var(--c-text) !important;
}

/* Settings / page tabs */
html.dark-mode .tabs:not(.jstTabs) > ul { border-bottom-color: var(--c-border) !important; }
html.dark-mode .tabs:not(.jstTabs) > ul li a { color: var(--c-text-subtle) !important; }
html.dark-mode .tabs:not(.jstTabs) > ul li a:hover { color: var(--c-text) !important; }
html.dark-mode .tabs:not(.jstTabs) > ul li a.selected { color: var(--c-primary-light, var(--c-primary)) !important; }

/* Tabular form dark mode */
html.dark-mode .tabular p { border-bottom-color: var(--c-border) !important; }
html.dark-mode .tabular label { color: var(--c-text-subtle) !important; }

/* Edit / Preview tab links in the wiki toolbar */
html.dark-mode #content .tabs ul li a,
html.dark-mode #content .jstTabs.tabs li a {
  background: var(--c-surface) !important;
  border-color: var(--c-border) !important;
  color: var(--c-text-muted) !important;
}
html.dark-mode #content .tabs ul li a.selected,
html.dark-mode #content .jstTabs.tabs li a.selected {
  background: var(--c-surface-2) !important;
  color: var(--c-text) !important;
  border-bottom-color: var(--c-surface-2) !important;
}

/* .box.tabular form container */
html.dark-mode .box.tabular {
  background: var(--c-surface) !important;
  border-color: var(--c-border) !important;
}
html.dark-mode .tabular label { color: var(--c-text-muted) !important; }

/* ── 27. JQUERY UI DIALOG (modal) ────────────────────────── */
/* Redmine calls showModal() which wraps content in ui-dialog with dialogClass:'modal' */
.ui-dialog.modal {
  padding: 0 !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  background: var(--c-surface) !important;
  font-family: var(--font-sans) !important;
  overflow: hidden !important;
}

.ui-dialog.modal .ui-dialog-titlebar {
  background: var(--c-surface) !important;
  border: none !important;
  border-bottom: 1px solid var(--c-border) !important;
  border-radius: 0 !important;
  padding: var(--sp-4) var(--sp-5) !important;
  display: flex !important;
  align-items: center !important;
  position: relative !important;
}

.ui-dialog.modal .ui-dialog-title {
  font-size: var(--text-base) !important;
  font-weight: 600 !important;
  color: var(--c-text) !important;
  float: none !important;
  margin: 0 !important;
}

.ui-dialog.modal .ui-dialog-titlebar-close {
  position: absolute !important;
  right: var(--sp-4) !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  background: transparent !important;
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r) !important;
  width: 28px !important;
  height: 28px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  color: var(--c-text-muted) !important;
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1 !important;
  transition: background var(--t-fast), border-color var(--t-fast) !important;
}

.ui-dialog.modal .ui-dialog-titlebar-close:hover {
  background: var(--c-surface-2) !important;
  border-color: var(--c-border-2) !important;
  color: var(--c-text) !important;
}

/* Show × close button: hide space+text, replace icon via ::before */
.ui-dialog.modal .ui-dialog-titlebar-close { font-size: 0 !important; }
.ui-dialog.modal .ui-dialog-titlebar-close .ui-button-icon-space { display: none !important; }
.ui-dialog.modal .ui-dialog-titlebar-close .ui-icon-closethick {
  background-image: none !important;
  width: 100% !important;
  height: 100% !important;
  text-indent: 0 !important;
  visibility: visible !important;
  position: static !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0px !important;
}
.ui-dialog.modal .ui-dialog-titlebar-close .ui-icon-closethick::before {
  content: '×' !important;
  font-size: 20px !important;
  line-height: 1 !important;
  color: var(--c-text-muted) !important;
  font-family: var(--font-sans) !important;
}

.ui-dialog.modal .ui-dialog-content {
  background: var(--c-surface) !important;
  color: var(--c-text) !important;
  padding: var(--sp-5) !important;
  border: none !important;
  font-family: var(--font-sans) !important;
  font-size: var(--text-sm) !important;
}

/* Overlay + dialog stacking — must exceed fixed topbar (1000), fixed header
   (999), floating widgets (#rm-darkmode-toggle/toast at 9998-9999), and
   specificity-bomb plugin rules like redmine_contacts' `div.ui-dialog`. */
body div.ui-widget-overlay,
body > .ui-widget-overlay,
.ui-widget-overlay {
  background: rgb(0 0 0 / .45) !important;
  opacity: 1 !important;
  z-index: 10050 !important;
}
body div.ui-dialog,
body > .ui-dialog,
.ui-dialog {
  z-index: 10051 !important;
}

/* Watcher user list */
#users_for_watcher {
  border: 1px solid var(--c-border) !important;
  border-radius: var(--r) !important;
  max-height: 200px !important;
  overflow-y: auto !important;
  padding: var(--sp-1) var(--sp-2) !important;
  margin: var(--sp-2) 0 var(--sp-3) !important;
  background: var(--c-surface) !important;
  scrollbar-width: thin !important;
}

#users_for_watcher label {
  display: flex !important;
  align-items: center !important;
  gap: var(--sp-2) !important;
  padding: var(--sp-1) var(--sp-2) !important;
  border-radius: var(--r-sm) !important;
  cursor: pointer !important;
  color: var(--c-text) !important;
}

#users_for_watcher label:hover { background: var(--c-surface-2) !important; }

/* Modal footer buttons */
.ui-dialog.modal p.buttons {
  display: flex !important;
  align-items: center !important;
  gap: var(--sp-3) !important;
  margin: var(--sp-4) 0 0 !important;
}

.ui-dialog.modal p.buttons a {
  font-size: var(--text-sm) !important;
  color: var(--c-text-muted) !important;
  text-decoration: none !important;
  padding: var(--sp-2) var(--sp-3) !important;
  border-radius: var(--r) !important;
  border: 1px solid var(--c-border) !important;
  transition: background var(--t-fast) !important;
}

.ui-dialog.modal p.buttons a:hover {
  background: var(--c-surface-2) !important;
  color: var(--c-text) !important;
}

.ui-dialog.modal p.buttons input[type=submit] {
  height: 36px !important;
  padding: 0 var(--sp-5) !important;
  font-size: var(--text-sm) !important;
  min-width: 80px !important;
}

/* Dark mode for modal */
html.dark-mode .ui-dialog.modal,
html.dark-mode .ui-dialog.modal .ui-dialog-titlebar,
html.dark-mode .ui-dialog.modal .ui-dialog-content { background: var(--c-surface) !important; border-color: var(--c-border) !important; }
html.dark-mode .ui-dialog.modal .ui-dialog-title { color: var(--c-text) !important; }
html.dark-mode #users_for_watcher { background: var(--c-surface-2) !important; border-color: var(--c-border) !important; }

/* ══════════════════════════════════════════════════════════
   COMPREHENSIVE DARK MODE — systematic hardcoded-color fixes
   ══════════════════════════════════════════════════════════ */

/* ── Table th cells (e.g. Issue tracking on overview) ── */
html.dark-mode table th,
html.dark-mode table.list th { background: var(--c-surface-2) !important; color: var(--c-text-muted) !important; border-color: var(--c-border) !important; }
html.dark-mode table.list td { border-color: var(--c-border) !important; }
html.dark-mode table.issue-report tr.total,
html.dark-mode table.issue-report-detailed tr.total { border-top-color: var(--c-border) !important; }

/* Group header rows (tr.group) */
html.dark-mode tr.group td,
html.dark-mode tr.group { background: var(--c-surface-2) !important; color: var(--c-text) !important; border-color: var(--c-border) !important; }

/* Total/summary rows */
html.dark-mode table#time-report tbody tr.total { background: var(--c-surface-2) !important; }
/* Class-based odd/even (issue list with odd-even class) */
html.dark-mode table.list tbody tr.odd  { background: var(--c-surface) !important; }
html.dark-mode table.list tbody tr.even { background: var(--c-surface-2) !important; }
/* nth-child alternating rows (overview, most non-issue-list tables) */
html.dark-mode table.list:not(.odd-even) tbody tr:nth-child(odd),
html.dark-mode .odd { background-color: var(--c-surface) !important; }
html.dark-mode table.list:not(.odd-even) tbody tr:nth-child(even),
html.dark-mode .even { background-color: var(--c-surface-2) !important; }
html.dark-mode table.list:not(.odd-even) tbody tr:nth-child(odd):hover,
html.dark-mode table.list:not(.odd-even) tbody tr:nth-child(even):hover,
html.dark-mode .odd:hover,
html.dark-mode .even:hover { background-color: var(--c-primary-light) !important; }
/* #issue-changesets alternating (same pattern) */
html.dark-mode #issue-changesets div.changeset:nth-child(odd)  { background: var(--c-surface) !important; }
html.dark-mode #issue-changesets div.changeset:nth-child(even) { background: var(--c-surface-2) !important; }

/* ── Flash messages (backgrounds) ── */
html.dark-mode div.flash.error,
html.dark-mode #errorExplanation { background-color: rgba(239,68,68,.15) !important; border-color: rgba(239,68,68,.4) !important; color: #FCA5A5 !important; }
html.dark-mode div.flash.notice  { background-color: rgba(16,185,129,.12) !important; border-color: rgba(16,185,129,.35) !important; color: #6EE7B7 !important; }
html.dark-mode div.flash.warning,
html.dark-mode .conflict          { background-color: rgba(245,158,11,.12) !important; border-color: rgba(245,158,11,.35) !important; color: #FCD34D !important; }

/* ── Context menu (context_menu.css) ── */
html.dark-mode #context-menu ul  { background: var(--c-surface) !important; border-color: var(--c-border) !important; }
html.dark-mode #context-menu li  { border-color: var(--c-surface) !important; color: var(--c-text) !important; }
html.dark-mode #context-menu li a { color: var(--c-text) !important; }
html.dark-mode #context-menu li:hover { background: var(--c-primary-light) !important; border-color: var(--c-primary) !important; }
html.dark-mode #context-menu li:hover a { color: var(--c-primary) !important; }
html.dark-mode #context-menu li a.disabled { color: var(--c-text-subtle) !important; }

/* ── Calendar ── */

/* ── Diff highlighting ── */
html.dark-mode .diff_out { background: rgba(239,68,68,.15) !important; }
html.dark-mode .diff_out span { background: rgba(239,68,68,.3) !important; }
html.dark-mode .diff_in  { background: rgba(16,185,129,.12) !important; }
html.dark-mode .diff_in span  { background: rgba(16,185,129,.25) !important; }

/* ── Syntax / code highlighting ── */
html.dark-mode .syntaxhl { background: var(--c-surface-2) !important; color: var(--c-text) !important; }
/* Syntax colours from the active palette, both modes. Core colours ~50 Rouge token types
   for a white background (#0000DD numbers, #333 operators, pink string backgrounds); here
   every token starts as plain text, and the groups below take --c-syn-* colours, which
   follow dark mode and the scheme (keyword ← info, string ← success, number ← warning,
   type ← magenta, function ← accent, tag ← danger). */
.syntaxhl span { color: var(--c-text) !important; background: transparent !important; }
.syntaxhl .hll { background: var(--c-syn-highlight) !important; }
.syntaxhl :is(.k, .kc, .kd, .kn, .kp, .kr, .ow, .nb, .bp) { color: var(--c-syn-keyword) !important; }
.syntaxhl :is(.kt, .nc, .nn, .no, .nd, .ne, .na) { color: var(--c-syn-type) !important; }
.syntaxhl :is(.nf, .fm) { color: var(--c-syn-function) !important; }
.syntaxhl :is(.s, .s1, .s2, .sa, .sb, .sc, .dl, .sd, .se, .sh, .si, .sx, .sr, .ss) { color: var(--c-syn-string) !important; }
.syntaxhl :is(.m, .mb, .mf, .mh, .mi, .mo, .il) { color: var(--c-syn-number) !important; }
.syntaxhl :is(.nt, .err, .gd, .gr, .gt) { color: var(--c-syn-tag) !important; }
.syntaxhl .gi { color: var(--c-syn-string) !important; }
.syntaxhl :is(.gh, .gu) { color: var(--c-syn-keyword) !important; font-weight: 600 !important; }
.syntaxhl :is(.c, .c1, .cm, .ch, .cs, .cp, .cpf, .gp, .go) { color: var(--c-syn-comment) !important; font-style: italic; }

/* ── Search/text highlight ── */
html.dark-mode .highlight { background: rgba(245,158,11,.3) !important; color: var(--c-text) !important; }
html.dark-mode .highlight.token-1 { background: rgba(239,68,68,.25) !important; }
html.dark-mode .highlight.token-2 { background: rgba(8,145,178,.25) !important; }

/* ── User mentions ── */
html.dark-mode a.user.user-mention { background: var(--c-primary-light) !important; color: var(--c-primary) !important; }

/* ── Progress bar cells (issue tracker) ── */
html.dark-mode table.progress td.todo   { background: var(--c-border) !important; }
html.dark-mode table.progress td.done   { background: rgba(16,185,129,.35) !important; }
html.dark-mode table.progress td.closed { background: rgba(16,185,129,.6) !important; }

/* ── Attachments / thumbnails ── */
html.dark-mode div.thumbnail { background: var(--c-surface) !important; border-color: var(--c-border) !important; }

/* ── Permissions table ── */
html.dark-mode table.fields_permissions td.readonly { background: var(--c-surface-2) !important; }
html.dark-mode table.fields_permissions td.required { background: rgba(239,68,68,.2) !important; }

/* ── Roadmap version summary ── */
html.dark-mode div#version-summary,
html.dark-mode div#issue-changesets { background: var(--c-surface) !important; border-color: var(--c-border) !important; }

/* ── Nodata / warning inline — remove yellow in all modes ── */
p.nodata, .nodata {
  background: var(--c-surface-2) !important;
  border-color: var(--c-border) !important;
  color: var(--c-text-muted) !important;
}

/* ── Login form ── */
html.dark-mode #login-form { background: var(--c-surface) !important; border-color: var(--c-border) !important; }

/* ── Sidebar hr ── */
html.dark-mode #sidebar hr { background: var(--c-border) !important; border-color: var(--c-border) !important; }

/* ── Wiki target highlight ── */
html.dark-mode div.wiki a:target + h1,
html.dark-mode div.wiki a:target + h2,
html.dark-mode div.wiki a:target + h3 { background: var(--c-primary-light) !important; }

/* ── Gantt & SCM areas ── */

/* ── Generic missing borders ── */
html.dark-mode .box,
html.dark-mode .box h3 { border-color: var(--c-border) !important; }
html.dark-mode hr { border-color: var(--c-border) !important; background: var(--c-border) !important; }

/* ── Project cards (#projects-index) ── */
html.dark-mode #projects-index ul.projects li.root,
html.dark-mode #projects-index ul.projects li.child { border-color: var(--c-border) !important; background: var(--c-surface) !important; }
html.dark-mode #projects-index li.root ul.projects { border-left-color: var(--c-border) !important; }
html.dark-mode #projects-index ul.projects div.root a.project { color: var(--c-primary) !important; }
html.dark-mode #projects-index ul.projects div.description { color: var(--c-text-muted) !important; }

/* ── Nav tabs active state — override Redmine's hardcoded #fff background ── */
html.dark-mode #main-menu li a.selected,
html.dark-mode #main-menu li a.selected:hover { background: transparent !important; color: var(--c-primary) !important; }

/* ── Activity page day headers ── */
html.dark-mode #activity h3 {
  background: var(--c-surface-2) !important;
  border-color: var(--c-border) !important;
  color: var(--c-text) !important;
}

/* ── Sidebar clear-query icon — ensure SVG renders ── */
a.icon-clear-query .icon-svg { display: block !important; }
a.icon-clear-query .icon-label { display: none !important; }
a.icon-clear-query {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 20px !important;
  height: 20px !important;
  flex-shrink: 0 !important;
}
/* The selected query and its Clear (×) link share one <li>. `#sidebar ul li a
   { display: flex }` made the query a full-width row and pushed the × under it (#12);
   same fix as the watchers list — one flex row, the query takes the remaining width. */
#sidebar ul li:has(> a.icon-clear-query) {
  display: flex !important;
  align-items: center !important;
  gap: var(--sp-1) !important;
}
#sidebar ul li:has(> a.icon-clear-query) > a:not(.icon-clear-query) { flex: 1 1 auto !important; min-width: 0 !important; }
/* Core keeps sidebar icon-only links at opacity .2 until hover — for the only way to
   clear the selected query that is too faint, and in core blue it vanished in dark mode */
#sidebar a.icon-clear-query svg { opacity: .8 !important; stroke: var(--c-text-muted) !important; }
#sidebar a.icon-clear-query:hover svg,
#sidebar a.icon-clear-query:focus-visible svg { opacity: 1 !important; stroke: var(--c-primary) !important; }

/* ── My page block drag areas ── */
html.dark-mode .mypage-box { background: var(--c-surface) !important; border-color: var(--c-border) !important; }
html.dark-mode .block-receiver { border-color: var(--c-border) !important; }

/* ── Activity page user/filter inputs in sidebar ── */
html.dark-mode #sidebar input[type=text],
html.dark-mode #sidebar select { background-color: var(--c-surface-2) !important; border-color: var(--c-border) !important; color: var(--c-text) !important; }

/* ── Plugin compatibility (dark mode) ─────────────────────── */
/* Plugins hardcode light backgrounds that the dark palette then puts light text on.
   Selectors are deliberately more specific than the plugin's (and !important only
   where the plugin uses it), so a plugin's own inline colour coding still wins.
   Checked against redmine.inctime.com, 2026-10-29. */

/* RedmineUP Agile — cards #ffffdd, planning columns #f6f7f8/#eee, WIP limits.
   Colour-coded cards (.bk-*) keep their meaning as a left stripe. */
html.dark-mode .issue-card { background-color: var(--c-surface-2); border-color: var(--c-border); color: var(--c-text); }
html.dark-mode .issues-board td.issue-status-col.closed .issue-card,
html.dark-mode .planning-board .closed-issue { background-color: var(--c-surface); opacity: .8; }
html.dark-mode .planning-board .closed-issue p.name a,
html.dark-mode .planning-board .closed-issue p.issue-id { color: var(--c-text-muted) !important; }
html.dark-mode .issue-card p.project,
html.dark-mode .assignable-user.draggable-active { background-color: var(--c-surface); border-color: var(--c-border); }
html.dark-mode .issue-card[class*="bk-"] { border-left-width: 4px; }
html.dark-mode .issue-card.bk-red        { border-left-color: var(--c-danger); }
html.dark-mode .issue-card.bk-green,
html.dark-mode .issue-card.bk-lightgreen { border-left-color: var(--c-success); }
html.dark-mode .issue-card.bk-blue       { border-left-color: var(--c-info); }
html.dark-mode .issue-card.bk-turquoise  { border-left-color: var(--c-primary); }
html.dark-mode .issue-card.bk-yellow,
html.dark-mode .issue-card.bk-orange     { border-left-color: var(--c-warning); }
html.dark-mode .issue-card.bk-purple     { border-left-color: var(--c-border-2); }
html.dark-mode .issue-card.bk-gray       { border-left-color: var(--c-text-subtle); }
html.dark-mode table.issues-board td.issue-status-col.closed,
html.dark-mode table.issues-board tbody td.under_wp_limit,
html.dark-mode table.issues-board tbody td.over_wp_limit { background-color: transparent; }
html.dark-mode table.issues-board thead th.under_wp_limit { background-color: color-mix(in srgb, var(--c-success) 18%, var(--c-surface)); }
html.dark-mode table.issues-board thead th.over_wp_limit  { background-color: color-mix(in srgb, var(--c-danger) 18%, var(--c-surface)); }
html.dark-mode .issues-board .backlog-column-header,
html.dark-mode .issues-board .issue-backlog-col { background: var(--c-surface); }
html.dark-mode .planning-board .column-content { background-color: var(--c-surface); border-color: var(--c-border); }
html.dark-mode .planning-board .column-header { background-color: var(--c-surface-2); border-bottom-color: var(--c-border); }
html.dark-mode .planning-board .column-header .version-name,
html.dark-mode .planning-board .column-header .version-estimate { color: var(--c-text-muted); }
html.dark-mode.agile-board-fullscreen div.agile-board { background: var(--c-bg); }

/* Redmineflux Testcase Management — #eaf7ff !important sidebar on ~25 controllers,
   white activity panel and filters. Its chart (#testcase_graph_id) is left white on
   purpose: the canvas draws dark axis labels that would vanish on a dark card. */
html.dark-mode body:is([class*="controller-test"], [class*="controller-run"], .controller-requirements,
  .controller-traceability_rtms, .controller-issue_testcase) #sidebar {
  background: var(--c-sidebar-bg) !important; box-shadow: none !important;
}
html.dark-mode #main #sidebar_right,
html.dark-mode #main .activity_item,
html.dark-mode #main .parent_calendar { background-color: var(--c-surface); color: var(--c-text); border-color: var(--c-border); }
html.dark-mode #main #reset_filters_button { background-color: var(--c-surface-2); color: var(--c-text); border: 1px solid var(--c-border); }
html.dark-mode #main .activity_detail_date { color: var(--c-text-muted); }
html.dark-mode #main .activity_date_heading { background-color: var(--c-surface-2); }
html.dark-mode #main .sidebar_right_header h5 span,
html.dark-mode #main .activity_date_heading .date_title { color: var(--c-text); }

/* Vault (Passwords) — search row: Find and Clear are two forms inside a flex h2 with
   no gap, the field is 24px next to 36px buttons, and Clear looked as primary as Find */
.controller-keys #content .keys-search-title { gap: var(--sp-2) !important; flex-wrap: wrap !important; }
.controller-keys #content .keys-search-form { display: flex !important; align-items: center !important; gap: var(--sp-2) !important; }
.controller-keys #content .keys-search-title input#query { height: 36px !important; }
.controller-keys #content .keys-search-title form.button_to input[type=submit] {
  background: var(--c-surface) !important;
  color: var(--c-text) !important;
  border-color: var(--c-border-2) !important;
}
.controller-keys #content .keys-search-title form.button_to input[type=submit]:hover { background: var(--c-surface-2) !important; }

/* Vault — popular tags: the plugin's 3-column layout squeezes each tag into ~56px of
   sidebar and the theme's #sidebar link style (muted text, 8px padding) clipped the
   label. Pills instead; white text on the user-chosen colour, as the plugin intends,
   dark text on its default bisque (no inline colour). */
#tags-list:has(li.vault-tag) { column-count: auto !important; }
#tags-list ul:has(> li.vault-tag) { display: flex !important; flex-wrap: wrap !important; gap: 6px !important; margin: 0 !important; padding: 0 !important; }
#tags-list li.vault-tag { margin: 0 !important; padding: 0 !important; overflow: visible !important; border-radius: 999px !important; }
#sidebar #tags-list li.vault-tag a.vault-tag-link {
  display: inline-block !important;
  padding: 2px 10px !important;
  font-size: var(--text-xs) !important;
  font-weight: 600 !important;
  color: white !important;
  background: transparent !important;
  border-radius: inherit !important;
}
#sidebar #tags-list li.vault-tag:not([style*="background"]) a.vault-tag-link { color: var(--c-text) !important; }
#sidebar #tags-list li.vault-tag a.vault-tag-link:hover { text-decoration: underline !important; }
/* Vault — key list (/keys/all, /projects/:id/keys, a key's page): core centres every
   table.list cell; names, logins and URLs read better from the left. */
#keys_table th,
#keys_table td { text-align: left !important; }

/* ── Colour schemes: hardcoded colours that would otherwise leak through ── */
/* Modern renders these values directly; a scheme re-expresses them from its
   tokens. Scoped to [data-scheme] so the default palette stays pixel-identical. */
@supports (color: color-mix(in srgb, red, white)) {
  /* Redmine core paints #content white; Modern light relies on that = --c-surface */
  html[data-scheme]:not(.dark-mode) #content { background-color: var(--c-surface) !important; }
  html[data-scheme] a.icon-only.icon-add,
  html[data-scheme] #content a.icon-only.icon-add,
  html[data-scheme] a.icon.new-issue,
  html[data-scheme] a.icon.icon-add { border-color: color-mix(in srgb, var(--c-primary) 25%, transparent) !important; }
  html[data-scheme].dark-mode .cal .calbody.nwday:not(.other-month) { background: color-mix(in srgb, var(--c-primary) 6%, transparent) !important; }
  html[data-scheme].dark-mode .cal .calbody.today { background: var(--c-primary-light) !important; }
  html[data-scheme].dark-mode .highlight.token-2 { background: color-mix(in srgb, var(--c-primary) 25%, transparent) !important; }

  /* Redmine core greys (#d0d7de, #ddd, #eee, #f7f7f7, #888, #666 …). Modern keeps
     them — they read as neutral next to its slate palette — but on a tinted scheme
     background they show up as cold grey patches, so map each to its token. */
  html[data-scheme] table.list,
  html[data-scheme] .table-list,
  html[data-scheme] table.list td,
  html[data-scheme] table.list th,
  html[data-scheme] .table-list-header,
  html[data-scheme] fieldset,
  html[data-scheme] .box,
  html[data-scheme] .mypage-box,
  html[data-scheme] #sidebar,
  html[data-scheme] #footer,
  html[data-scheme] ul.cal,
  html[data-scheme] .cal .calbody,
  html[data-scheme] div.issue,
  html[data-scheme] #projects-index ul.projects li.root,
  html[data-scheme] .filecontent.wiki,
  html[data-scheme] tr.group td,
  html[data-scheme] div#sticky-issue-header,
  html[data-scheme] ul.pages li,
  html[data-scheme] div#issue-changesets div.changeset { border-color: var(--c-border) !important; }
  html[data-scheme] table.list th,
  html[data-scheme] .table-list-header,
  html[data-scheme] .cal .calhead,
  html[data-scheme] .cal .week-number { background-color: var(--c-surface-2) !important; }
  html[data-scheme] legend { color: var(--c-text-muted) !important; }
  html[data-scheme] span.pagination,
  html[data-scheme] p.other-formats,
  html[data-scheme] .journals .journal-details,
  html[data-scheme] ul.revision-info,
  html[data-scheme] em.info,
  html[data-scheme] div.attachments span.author,
  html[data-scheme] .wiki-update-info,
  html[data-scheme] div#activity dd span.description,
  html[data-scheme] .cal .day-num,
  html[data-scheme] .task,
  html[data-scheme] div.issue div.subject p,
  html[data-scheme] div.issue .next-prev-links,
  html[data-scheme] .gantt_hdr.nwday { color: var(--c-text-muted) !important; }
  html[data-scheme] span.required { color: var(--c-danger) !important; }

  /* Current page, selected sidebar query, count badge — core #628DB6 / #9DB9D5 */
  html[data-scheme] ul.pages li.current,
  html[data-scheme] #sidebar a.selected,
  html[data-scheme] .badge-count {
    background-color: var(--c-primary) !important;
    border-color: var(--c-primary) !important;
    color: var(--c-on-primary) !important;
  }
  html[data-scheme] #sidebar a.selected svg.icon-svg { stroke: var(--c-on-primary) !important; }
  html[data-scheme] .badge-status-open { color: var(--c-primary) !important; border-color: var(--c-primary) !important; }

  /* Wiki toolbar (jstoolbar.css: #f7f7f7 / #ddd) */
  html[data-scheme] .jstElements button,
  html[data-scheme] .jstTabs.tabs ul li a { background-color: var(--c-surface-2) !important; border-color: var(--c-border) !important; }
  html[data-scheme]:not(.dark-mode) #content .jstTabs.tabs li a.selected {
    background-color: var(--c-surface) !important;
    border-bottom-color: var(--c-surface) !important;
  }

  /* Calendar and gantt */
  html[data-scheme] .cal .calbody.other-month { background-color: var(--c-bg) !important; }
  html[data-scheme] .cal .calbody.nwday:not(.other-month),
  html[data-scheme] .gantt_hdr.nwday { background-color: var(--c-surface-2) !important; }
  html[data-scheme] .cal .calbody.today { background-color: var(--c-primary-light) !important; }
  html[data-scheme] .gantt_hdr { border-color: var(--c-border-2) !important; background-color: var(--c-surface-2) !important; }
  html[data-scheme]:not(.dark-mode) table.list:not(.odd-even) tbody tr:nth-child(even),
  html[data-scheme]:not(.dark-mode) .even,
  html[data-scheme]:not(.dark-mode) div#activity h3 { background-color: var(--c-surface-2) !important; }

  /* Light schemes: core .box is #f9fafb, form controls are #fff */
  html[data-scheme]:not(.dark-mode) .box { background-color: var(--c-surface-2) !important; color: var(--c-text) !important; }
  html[data-scheme]:not(.dark-mode) input[type=text],
  html[data-scheme]:not(.dark-mode) input[type=email],
  html[data-scheme]:not(.dark-mode) input[type=password],
  html[data-scheme]:not(.dark-mode) input[type=number],
  html[data-scheme]:not(.dark-mode) input[type=search],
  html[data-scheme]:not(.dark-mode) input[type=url],
  html[data-scheme]:not(.dark-mode) input[type=date],
  html[data-scheme]:not(.dark-mode) select,
  html[data-scheme]:not(.dark-mode) textarea { background-color: var(--c-surface) !important; color: var(--c-text) !important; }

  /* Native checkboxes / radios / range follow the accent */
  html[data-scheme] input[type=checkbox],
  html[data-scheme] input[type=radio] { accent-color: var(--c-primary); }
}

/* Hide default Redmine footer attribution (white-labeled as Team Pulse) */
#footer { display: none !important; }
