* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --root-font-size: 16px;
}

/* Texts' footnote markers, which the "Show superscripts" setting hides when it's off (src/workspace.js), in atoms'
   shadow roots too */
:root[data-hide-superscripts] {
  --footnote-marker-display: none;
}

/* Texts' section headings, which the "Show section headings" setting hides when it's off (src/workspace.js) */
:root[data-hide-section-headings] {
  --section-heading-display: none;
}

/*
 * Colours, by what they're for. Components use these rather than colours of their own, so the theme can change them
 * all; they reach into components' shadow roots, as custom properties are inherited. The theme is the html element's
 * data-theme, set before the page draws (public/js/theme.js) and by the settings menu (src/utils/theme.js).
 */
:root {
  color-scheme: light;

  --active-color: #006bff;
  --hover-color: #c3dcff;
  --mousedown-color: #8abbff;

  /* Backgrounds: the page, a menu or popover over it, hovered, pressed or selected */
  --surface: #ffffff;
  --surface-raised: #f9f9f9;
  --surface-hover: #f4f4f4;
  --surface-pressed: #e8e8e8;
  /* Laid over whatever is under it, eg a hovered row */
  --tint: rgba(0, 0, 0, 0.06);
  --tint-strong: rgba(0, 0, 0, 0.1);

  /* Lines: between sections, around controls, a hovered or focused control's, and a focused control's ring */
  --divider: #e0e0e0;
  --border: #c8c8c8;
  --border-hover: #aaaaaa;
  --border-focus: #888888;
  --focus-ring: #e8e8e8;

  /* The page's own text; components' is --text */
  --text-body: #213547;
  --text: #222222;
  --text-secondary: #444444;
  --text-muted: #777777;
  --text-faint: #b4b4b4;
  --text-warning: #b45309;

  /* Tables in module text: cell fills and edge lines, the shades desktop draws */
  --table-fill-light: #dfdfdf;
  --table-fill-dark: #696969;
  --table-fill-black: #000000;
  --table-edge: #000000;

  /* The BETA badge, in the top bar, the library's "Powered by" and the beta notice */
  --beta-badge: #1565d8;

  /* Close button on hover */
  --close-hover-bg: #e5484d;
  --close-hover-text: #ffffff;

  /* A problem worth noticing that isn't an error, eg the library failing to refresh */
  --notice-bg: #fbefc6;
  --notice-border: #ecd28a;
  --notice-text: #6b4f00;
  --notice-strong: #c9961a;

  /* Linked documents, and anything else that's "on": the search pills, the selected suggestion */
  --linked-bg: #c6efd3;
  --linked-bg-hover: #b2e6c3;
  --linked-border: #a3dcb6;
  --linked-text: #14602f;
  --linked-strong: #2f9e5b;
  --linked-strip: #2f9e5b66;

  /* Dragging a document, and a document that just opened in the rail */
  --accent: #4a90d9;
  --accent-bg: #d6e8fb;
  --accent-glow: #4a90d966;

  /* In texts */
  --link: blue;
  --reference: teal;
  /* Dark enough to read as text on white (about 4.8:1); plain orange is about 2:1 */
  --hit: #b35900;
  --hit-on-ink: #c86400;
  --hit-on-hover: #5c2e00;
  --word-hover: goldenrod;
  --cross-hit: rgba(218, 165, 32, 0.45);
  /* Highlighter ink as r, g, b, for rgba() with the stroke's varying strength */
  --highlight-ink: 238, 232, 170;
  --highlight-blend: multiply;
  /* Glows on hits, which tint what's under them */
  --glow-blend: multiply;

  --popover-shadow: #666666;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --active-color: #4c9aff;
  --hover-color: #1f3d66;
  --mousedown-color: #2b5590;

  --surface: #1c1d20;
  --surface-raised: #26272b;
  --surface-hover: #2e2f34;
  --surface-pressed: #393a40;
  --tint: rgba(255, 255, 255, 0.07);
  --tint-strong: rgba(255, 255, 255, 0.12);

  --divider: #303136;
  --border: #44454b;
  --border-hover: #5a5b62;
  --border-focus: #7c7d84;
  --focus-ring: #393a40;

  --text-body: #e3e4e8;
  --text: #e3e4e8;
  --text-secondary: #c2c3c8;
  --text-muted: #9a9ba2;
  --text-faint: #63646b;

  --table-fill-light: #393939;
  --table-fill-dark: #696969;
  --table-fill-black: #000000;
  --table-edge: var(--text);
  --text-warning: #f0a35c;
  --beta-badge: #5ea8ff;

  --close-hover-bg: #d13438;
  --close-hover-text: #ffffff;

  --notice-bg: #3a3017;
  --notice-border: #5c4a1c;
  --notice-text: #f0d58a;
  --notice-strong: #c9961a;

  --linked-bg: #1b3a27;
  --linked-bg-hover: #22482f;
  --linked-border: #2e5e40;
  --linked-text: #8edba9;
  --linked-strong: #46b974;
  --linked-strip: #46b97466;

  --accent: #5b9fe6;
  --accent-bg: #1d3550;
  --accent-glow: #5b9fe666;

  --link: #7fb2ff;
  --reference: #4fc1c1;
  --hit: #ffa94d;
  --hit-on-ink: #ffb366;
  --hit-on-hover: #ffe0b8;
  --word-hover: #7a5f10;
  --cross-hit: rgba(218, 165, 32, 0.3);
  --highlight-ink: 112, 98, 28;
  --highlight-blend: screen;
  --glow-blend: normal;

  --popover-shadow: #000000;

  /* Module text colours (src/color.js), which the light theme takes as they are. Dark ones are lightened to read on
     the dark background; black (and navy, which the desktop draws black) is the text colour. */
  --text-color-1: var(--text);
  --text-color-2: #9a9a9a;
  --text-color-3: #ff6b6b;
  --text-color-4: #4fd6d6;
  --text-color-5: #5fb3b3;
  --text-color-7: #ff9e9e;
  --text-color-8: #c98a8a;
  --text-color-9: #a5b7b7;
  --text-color-10: #5ce6e6;
  --text-color-11: #33f3f3;
  --text-color-12: #ff5c5c;
  --text-color-14: #d87070;
  --text-color-15: #e0a0a0;
  --text-color-16: #e06666;
  --text-color-17: var(--text);
  --text-color-18: #4db8b8;
  --text-color-19: #4fbcbc;
  --text-color-20: #c99494;
  --text-color-22: #4cbaba;
}

html {
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
  font-size: var(--root-font-size);
  line-height: 1.5;
  font-weight: 400;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  color: var(--text-body);
  background-color: var(--surface);

  /* Checkboxes and sliders in the app's "on" green rather than the browser's blue */
  accent-color: var(--linked-strong);
}

/* No 100vw/100vh: 100vw includes a classic scrollbar's width, and 100vh is taller than the visible area on mobile */
body {
  margin: 0;
  min-height: 100dvh;
}
