/* AOA colour and fonts on Todoist Comms: the same palette and type roles as
   theme.css on Twist. Colour and font overrides only; Comms owns layout,
   sizing, icons and theme state ([data-theme] on the root). Comms reads its
   colours from product-library tokens and its type from --td-ui-font-family.
   Row hover, selected and track fills must be opaque: Comms fades the end of a
   row into its fill (a gradient behind the hover actions) to cover the channel
   pill, so a translucent fill lets both show through. They are the AOA tints
   pre-blended over the surface they sit on. */
html:root {
  --font-head: "Poppins", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Helvetica", "Helvetica Neue", Arial, sans-serif;
  --surface: #fafafa;
  --side: #34465c;
  --side-edge: transparent;
  --side-active: #323d4d;
  --card: #eaeff5;
  --heading: #34465c;
  --body: #323d4d;
  --muted: #666666;
  --faint: #8a96a5;
  --border: rgba(52, 70, 92, 0.14);
  --border-soft: rgba(52, 70, 92, 0.07);
  --border-strong: rgba(52, 70, 92, 0.22);
  --track: #eaeff5;
  --hover: #eeeff1; /* rgba(52, 70, 92, 0.06) over #fafafa */
  --accent-soft: #d4dfe9;
  --done-bg: #34465c;
  --done-hover: #2a3a4d;
  --done-disabled: #a9b6c5;
  --done-fg: #ffffff;
  --aoa-link: #026696;
  --aoa-link-hover: #014e73;
  --aoa-orange: #f5931b;
  --aoa-sidebar-text: rgba(250, 250, 250, 0.92);
  --aoa-sidebar-muted: rgba(255, 255, 255, 0.75);
  --aoa-sidebar-faint: rgba(255, 255, 255, 0.55);
  --aoa-sidebar-hover: #445569; /* rgba(255, 255, 255, 0.08) over #34465c */
  --aoa-sidebar-rule: rgba(255, 255, 255, 0.12);
  --page-raised: #ffffff;
  --page-sunk: #eaeff5;
  --tab-on-bg: #34465c;
  --tab-on-fg: #ffffff;
  --tab-off-fg: #34465c;
}

html:root[data-theme="dark"] {
  --surface: #161b21;
  --side: #161b21;
  --side-edge: rgba(255, 255, 255, 0.08);
  --side-active: #292d33; /* rgba(255, 255, 255, 0.08) over #161b21 */
  --card: #1d232a;
  --heading: #fafafa;
  --body: rgba(250, 250, 250, 0.78);
  --muted: rgba(250, 250, 250, 0.55);
  --faint: rgba(250, 250, 250, 0.42);
  --border: rgba(255, 255, 255, 0.12);
  --border-soft: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.2);
  --track: #24292e; /* rgba(255, 255, 255, 0.06) over #161b21 */
  --hover: #22262c; /* rgba(255, 255, 255, 0.05) over #161b21 */
  --aoa-sidebar-hover: #22262c;
  --accent-soft: #3b2e1f;
  --done-bg: #f5931b;
  --done-hover: #f7a440;
  --done-disabled: #4a3a24;
  --done-fg: #161b21;
  --aoa-link: #f5931b;
  --aoa-link-hover: #f7a440;
  --page-raised: #1f262e;
  --page-sunk: #12161b;
  --tab-on-bg: rgba(255, 255, 255, 0.12);
  --tab-on-fg: #fafafa;
  --tab-off-fg: rgba(250, 250, 250, 0.65);
}

/* Map AOA tokens onto Comms' tokens. html:root outranks both of Comms' theme
   blocks (:root[data-theme=light|dark]). */
html:root,
html:root[data-theme] {
  --td-ui-font-family: var(--font-body);

  --product-library-background-base-primary: var(--surface);
  --product-library-background-base-secondary: var(--surface);
  --product-library-background-base-tertiary: var(--card);
  --product-library-background-grouped-primary: var(--surface);
  --product-library-background-grouped-secondary: var(--card);
  --product-library-background-grouped-tertiary: var(--card);
  --product-library-background-raised-primary: var(--page-raised);
  --product-library-background-raised-secondary: var(--card);

  --product-library-display-primary-idle-tint: var(--heading);
  --product-library-display-secondary-idle-tint: var(--muted);
  --product-library-display-tertiary-idle-tint: var(--faint);
  --product-library-display-accent-primary-fill: var(--aoa-link);
  --product-library-display-accent-primary-tint: var(--aoa-link);
  --product-library-display-accent-secondary-fill: var(--accent-soft);

  --product-library-divider-primary: var(--border);
  --product-library-divider-secondary: var(--border-soft);
  --product-library-divider-tertiary: var(--border-strong);
  --product-library-border-idle-tint: var(--border);
  --product-library-border-hover-tint: var(--border-strong);

  --product-library-actionable-focus-tint: var(--aoa-orange);
  --product-library-actionable-primary-idle-fill: var(--done-bg);
  --product-library-actionable-primary-hover-fill: var(--done-hover);
  --product-library-actionable-primary-disabled-fill: var(--done-disabled);
  --product-library-actionable-primary-on-idle-tint: var(--done-fg);
  --product-library-actionable-primary-on-hover-tint: var(--done-fg);
  --product-library-actionable-primary-on-dark-idle-fill: var(--aoa-link);
  --product-library-actionable-primary-on-dark-hover-fill: var(--aoa-link-hover);
  --product-library-actionable-tertiary-idle-tint: var(--aoa-link);
  --product-library-actionable-tertiary-hover-tint: var(--aoa-link-hover);
  --product-library-actionable-tertiary-on-hover-fill: var(--aoa-link);
  --product-library-actionable-tertiary-on-hover-tint: var(--aoa-link);
  --product-library-actionable-tertiary-on-dark-idle-tint: #7cc4ea;
  --product-library-actionable-tertiary-on-dark-hover-tint: #a9dbf3;
  --product-library-actionable-tertiary-on-dark-on-hover-fill: #7cc4ea;
  --product-library-actionable-tertiary-on-dark-on-hover-tint: #7cc4ea;

  --product-library-selectable-background: var(--track);
  --product-library-selectable-primary-selected-fill: var(--done-bg);
  --product-library-selectable-primary-selected-tint: var(--aoa-link);
  --product-library-selectable-primary-on-selected-fill: var(--done-fg);
  --product-library-selectable-primary-on-selected-tint: var(--done-fg);
  --product-library-selectable-secondary-idle-tint: var(--heading);
  --product-library-selectable-secondary-hover-fill: var(--hover);
  --product-library-selectable-secondary-selected-fill: var(--track);
  --product-library-selectable-secondary-on-selected-fill: var(--aoa-link);
  --product-library-selectable-secondary-on-selected-tint: var(--heading);

  /* Tabs (Inbox Active/Cleared): the selected tab is solid, as on Twist. */
  --td-ui-tab-neutral-track: var(--track);
  --td-ui-tab-neutral-selected-fill: var(--tab-on-bg);
  --td-ui-tab-neutral-selected-tint: var(--tab-on-fg);
  --td-ui-tab-neutral-unselected-tint: var(--tab-off-fg);
  --td-ui-tab-neutral-hover-tint: var(--heading);
}

html:root[data-theme="dark"] {
  --product-library-background-base-tertiary: var(--page-sunk);
  --product-library-background-raised-secondary: #26303a;
  --product-library-background-raised-tertiary: #2c3743;
  --product-library-background-raised-quaternary: #33404d;
  --product-library-actionable-focus-fill: #26303a;
  --product-library-selectable-secondary-selected-fill: var(--side-active);
  --product-library-selectable-secondary-on-selected-tint: #fafafa;
}

html, body { font-family: var(--font-body); }

/* Poppins for the same roles as on Twist: headings, names, navigation and
   controls. Message text, channel names and inputs stay Helvetica. */
#app :is(h1, h2, h3, h4, h5, h6, [role="heading"], button, [role="button"], [role="tab"], address[class*="_userName_"], [class*="_rowTitleText_"]) {
  --td-ui-font-family: var(--font-head);
  font-family: var(--font-head);
}
#app :is([class*="_markdown_"], [contenteditable="true"], textarea, input) {
  --td-ui-font-family: var(--font-body);
  font-family: var(--font-body);
}

/* The sidebar is AOA dark blue in light mode, with light text; in dark mode it
   shares the page colour with a hairline edge, as on Twist. Menus and dialogs
   render outside #sidebar, so they keep the page palette. */
#sidebar {
  --product-library-background-base-secondary: var(--side);
  --product-library-display-primary-idle-tint: var(--aoa-sidebar-text);
  --product-library-display-secondary-idle-tint: var(--aoa-sidebar-muted);
  --product-library-display-tertiary-idle-tint: var(--aoa-sidebar-faint);
  --product-library-display-accent-primary-fill: var(--aoa-orange);
  --product-library-display-accent-primary-tint: var(--aoa-orange);
  --product-library-divider-primary: var(--aoa-sidebar-rule);
  --product-library-divider-secondary: var(--aoa-sidebar-rule);
  --product-library-divider-tertiary: var(--aoa-sidebar-rule);
  --product-library-actionable-tertiary-idle-tint: var(--aoa-orange);
  --product-library-actionable-tertiary-hover-tint: #f7a440;
  --product-library-actionable-tertiary-hover-fill: var(--aoa-sidebar-hover);
  --product-library-actionable-quaternary-idle-tint: var(--aoa-sidebar-muted);
  --product-library-actionable-quaternary-hover-tint: #ffffff;
  --product-library-actionable-quaternary-hover-fill: var(--aoa-sidebar-hover);
  --product-library-actionable-quaternary-selected-fill: var(--side-active);
  --product-library-actionable-quaternary-on-selected-tint: #ffffff;
  --product-library-actionable-secondary-idle-fill: var(--aoa-sidebar-hover);
  --product-library-actionable-secondary-hover-fill: var(--aoa-sidebar-rule);
  --product-library-actionable-secondary-on-idle-tint: var(--aoa-sidebar-text);
  --product-library-actionable-secondary-on-hover-tint: #ffffff;
  --product-library-selectable-secondary-idle-tint: var(--aoa-sidebar-text);
  --product-library-selectable-secondary-hover-fill: var(--aoa-sidebar-hover);
  --product-library-selectable-secondary-selected-fill: var(--side-active);
  --product-library-selectable-secondary-on-selected-fill: #ffffff;
  --product-library-selectable-secondary-on-selected-tint: #ffffff;
  /* "New thread": light text with a warm orange icon. */
  --product-library-selectable-primary-selected-tint: var(--aoa-sidebar-text);
  color: var(--aoa-sidebar-text);
}
#sidebar [class*="_newThreadButton_"] svg { color: var(--aoa-orange); }
#sidebar nav[class*="_sidebar_"] {
  background-color: var(--side);
  box-shadow: inset -1px 0 0 var(--side-edge);
}
#sidebar a {
  --td-ui-font-family: var(--font-head);
  font-family: var(--font-head);
}
#sidebar :is(a[href*="/ch/"], [class*="_titleButton_"]) {
  --td-ui-font-family: var(--font-body);
  font-family: var(--font-body);
}

/* Keyboard focus is AOA orange everywhere. */
#app :is(button, a, input, textarea, [role="button"], [tabindex]):focus-visible {
  outline-color: var(--aoa-orange);
}
