/* Theme: El Jefe's Shisha Lounge. Neon signage on a charcoal wall: flat
   fills, no shadows, no gradients, one family (Inter).

   Four layers of tokens, each built on the one before:
   1. Brand: the design system's tokens under its own names: the neon pairs
      (a bright colour and its deep partner), the two surfaces, the inks, the
      tint, the radii and the stroke. Only these hold raw values.
   2. Tones: the four colours as the theme shows them, each a pair: --blue is
      the colour itself, the one that is seen (lines, text, what is lit), and
      --blue-bg the ground it sits on. At Night they are the brand's pairs:
      neon on its deep partner. By Day, where neon does not read and the deep
      colours are heavy, both are mixed from the pair: a stronger colour on a
      pale wash of it. The stylesheet below uses the tones, never the brand's
      colours directly, so each theme is light or dark throughout.
   3. Roles: what a colour means in the app, each a pair --x and --on-x:
        --accent   what is selected, switched on or drawn (notes, steps, tabs)
        --time     where the song is: playhead, loop, the scene that plays
        --go / --warn / --rec   play and solo / mute and pause / record and errors
      A fill is `background: --x; color: --on-x`, a line is --x. The two of a
      pair always go together: never one neon on another.
   4. Hues: one tone per page of the sound panel, --hue and --hue-bg: the
      page's tab and the titles, knobs and displays of its modules, lines on
      a ground like the brand's neon art. Source is blue, Shape pink, Motion
      green, Effects yellow. (The brand keeps green rare; this app uses all
      four alike, to tell things apart.)

   Night is the primary theme. The app sets data-theme="day" for Day and
   data-contrast="more" for more contrast (see setLook in app.js). */
:root {
  /* 1. Brand */
  --neon-blue: #0099ff;
  --neon-blue-deep: #00263f;
  --neon-pink: #ff0099;
  --neon-pink-deep: #3f0026;
  --neon-yellow: #ffcc00;
  --neon-yellow-deep: #3f3200;
  --neon-green: #00ff99;
  --neon-green-deep: #003f26;
  --surface-100: #333333; /* the wall: the page, and what is set into a panel */
  --surface-200: #262626; /* cards and panels on it */
  --ink: #ffffff;
  --ink-muted: #bdbdbd;
  --border: #ffffff1f; /* a tint of ink: the fill of plain controls. Never a line */
  --font-sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, Menlo, Consolas, monospace; /* not the brand's: code needs one */
  /* 3, 6 and 8px at 16px text: the shapes of the panels' own tabs and menus;
     in rem, to scale with the rest */
  --radius-sm: 0.1875rem; /* tags, wells, handles, steps */
  --radius-control: 0.375rem; /* buttons and boxes */
  --radius-md: 0.5rem; /* cards: modules, mixer strips, menus */
  --stroke-line: 2px; /* neon outlines */
  color-scheme: dark;

  /* What follows from those */
  --border-strong: color-mix(in srgb, var(--ink) 24%, transparent); /* the tint twice: hover, troughs */
  --raised: color-mix(in srgb, var(--ink) 12%, var(--surface-100)); /* the tint on the wall: menus, the master strip */
  --rule: color-mix(in srgb, var(--ink) 40%, transparent); /* the lines of the grids */
  --ink-soft: color-mix(in srgb, var(--ink) 75%, transparent); /* secondary text on a tinted control, where --ink-muted is too faint */
  --handle: var(--ink); /* the handles of faders and sliders */
  --line: transparent; /* outlines of cards and wells: none, the look is flat (ink with more contrast) */
  --hairline: color-mix(in srgb, var(--ink) 10%, transparent); /* the edge of controls and cards */
  --well: color-mix(in srgb, var(--ink) 4%, transparent); /* the inside of text boxes and menus */
  --card: color-mix(in srgb, var(--ink) 3%, transparent); /* the fill of a card on its panel */
  /* the keys of a piano are white and black in any theme */
  --key-white: #fafafa;
  --key-white-hover: #ebebeb;
  --key-black: #262626;
  --key-black-hover: #333333;
  --key-edge: #bdbdbd;

  /* 2. Tones */
  --blue: var(--neon-blue);
  --blue-bg: var(--neon-blue-deep);
  --pink: var(--neon-pink);
  --pink-bg: var(--neon-pink-deep);
  --yellow: var(--neon-yellow);
  --yellow-bg: var(--neon-yellow-deep);
  --green: var(--neon-green);
  --green-bg: var(--neon-green-deep);

  /* 3. Roles */
  --accent: var(--blue);
  --on-accent: var(--blue-bg);
  --time: var(--yellow);
  --on-time: var(--yellow-bg);
  --go: var(--green);
  --on-go: var(--green-bg);
  --warn: var(--yellow);
  --on-warn: var(--yellow-bg);
  --rec: var(--pink);
  --on-rec: var(--pink-bg);
  --focus: var(--pink);
  /* the insides of the letters of the name */
  --blue-title: var(--blue-bg);
  --pink-title: var(--pink-bg);
  --yellow-title: var(--yellow-bg);
  --green-title: var(--green-bg);

  /* 4. Hues: blue unless a module says otherwise */
  --hue: var(--blue);
  --hue-bg: var(--blue-bg);
}

:root[data-theme="day"] {
  --surface-100: #fafafa;
  --surface-200: #ebebeb;
  --ink: #1a1a1a;
  --ink-muted: #5c5c5c;
  --border: #0000001f;
  color-scheme: light;
  /* Each colour is its neon darkened with its deep partner until it reads as
     text on the surfaces (yellow and green are light, and take more of it);
     each ground is a wash of the neon over the wall. */
  --blue: color-mix(in srgb, var(--neon-blue) 55%, var(--neon-blue-deep));
  --blue-bg: color-mix(in srgb, var(--neon-blue) 16%, var(--surface-100));
  --pink: color-mix(in srgb, var(--neon-pink) 55%, var(--neon-pink-deep));
  --pink-bg: color-mix(in srgb, var(--neon-pink) 14%, var(--surface-100));
  --yellow: color-mix(in srgb, var(--neon-yellow) 30%, var(--neon-yellow-deep));
  --yellow-bg: color-mix(in srgb, var(--neon-yellow) 22%, var(--surface-100));
  --green: color-mix(in srgb, var(--neon-green) 30%, var(--neon-green-deep));
  --green-bg: color-mix(in srgb, var(--neon-green) 16%, var(--surface-100));
  --handle: var(--ink-muted); /* softer than ink */
  /* the letters of the name are lit: a pale inside would leave them hollow */
  --blue-title: var(--neon-blue);
  --pink-title: var(--neon-pink);
  --yellow-title: var(--neon-yellow);
  --green-title: var(--neon-green);
  /* the black keys are softer too */
  --key-black: #5c5c5c;
  --key-black-hover: #707070;
}

/* More contrast: black or white surfaces, and every card and well outlined
   (the controls are outlined further down). */
:root[data-contrast="more"] {
  --surface-100: #000000;
  --surface-200: #000000;
  --ink-muted: #d6d6d6;
  --line: var(--ink);
  --rule: color-mix(in srgb, var(--ink) 70%, transparent);
}
:root[data-theme="day"][data-contrast="more"] {
  --surface-100: #ffffff;
  --surface-200: #ffffff;
  --ink: #000000;
  --ink-muted: #2b2b2b;
  --handle: var(--ink);
  /* the colours darker still */
  --blue: color-mix(in srgb, var(--neon-blue) 35%, var(--neon-blue-deep));
  --pink: color-mix(in srgb, var(--neon-pink) 35%, var(--neon-pink-deep));
  --yellow: color-mix(in srgb, var(--neon-yellow) 20%, var(--neon-yellow-deep));
  --green: color-mix(in srgb, var(--neon-green) 15%, var(--neon-green-deep));
  --key-black: #2b2b2b;
  --key-black-hover: #404040;
}

/* Editor themes: the palettes of popular code editors, set with data-look on
   top of data-theme (night for a dark one, day for a light one). Each gives
   the surfaces, the inks and its own blue, pink, yellow and green; the rest
   follows as it does for Night and Day. Where a colour of the theme would be
   too faint to read here, it is mixed with white (on dark) or black (on
   light) just far enough; a light theme keeps the colour as it is for the
   letters of the name (--x-title). */
:root[data-look] { --border: color-mix(in srgb, var(--ink) 12%, transparent); }
/* the grounds: a quarter of the colour's brightness, as the brand's deep
   colours are, or a wash of it over the wall */
:root[data-look][data-theme="night"] {
  --blue-bg: color-mix(in srgb, var(--blue) 25%, black);
  --pink-bg: color-mix(in srgb, var(--pink) 25%, black);
  --yellow-bg: color-mix(in srgb, var(--yellow) 25%, black);
  --green-bg: color-mix(in srgb, var(--green) 25%, black);
}
/* The piano keys in the look's own colours (El Jefe's looks keep a real
   piano's): on dark, white keys of the text colour over the wall and black
   keys of the deeper wall; on light, white keys paler than the wall and
   black keys of the text colour. Each key's name is in the other's colour. */
:root[data-look][data-theme="night"] {
  --key-white: color-mix(in srgb, var(--ink) 82%, var(--surface-100));
  --key-white-hover: color-mix(in srgb, var(--ink) 70%, var(--surface-100));
  --key-black: var(--surface-200);
  --key-black-hover: color-mix(in srgb, var(--ink) 14%, var(--surface-200));
  --key-edge: color-mix(in srgb, var(--ink) 45%, var(--surface-100));
}
:root[data-look][data-theme="day"] {
  --key-white: color-mix(in srgb, var(--surface-100) 55%, white);
  --key-white-hover: var(--surface-200);
  --key-black: color-mix(in srgb, var(--ink) 88%, var(--surface-100));
  --key-black-hover: color-mix(in srgb, var(--ink) 72%, var(--surface-100));
  --key-edge: color-mix(in srgb, var(--ink) 25%, var(--surface-100));
}
:root[data-look][data-theme="day"] {
  --blue-bg: color-mix(in srgb, var(--blue-title) 16%, var(--surface-100));
  --pink-bg: color-mix(in srgb, var(--pink-title) 16%, var(--surface-100));
  --yellow-bg: color-mix(in srgb, var(--yellow-title) 16%, var(--surface-100));
  --green-bg: color-mix(in srgb, var(--green-title) 16%, var(--surface-100));
}
:root[data-look="synthwave"] { /* Synthwave '84 */
  --surface-100: #262335;
  --surface-200: #1e1a2b;
  --ink: #f4eeff;
  --ink-muted: color-mix(in srgb, #a599c7 88%, white);
  --blue: #36f9f6;
  --pink: #ff7edb;
  --yellow: #fede5d;
  --green: #72f1b8;
}
:root[data-look="tokyonight"] { /* Tokyo Night */
  --surface-100: #1a1b26;
  --surface-200: #16161e;
  --ink: #c0caf5;
  --ink-muted: color-mix(in srgb, #737aa2 76%, white);
  --blue: #7aa2f7;
  --pink: #f7768e;
  --yellow: #e0af68;
  --green: #9ece6a;
}
:root[data-look="mocha"] { /* Catppuccin Mocha */
  --surface-100: #1e1e2e;
  --surface-200: #181825;
  --ink: #cdd6f4;
  --ink-muted: #a6adc8;
  --blue: #89b4fa;
  --pink: #f5c2e7;
  --yellow: #f9e2af;
  --green: #a6e3a1;
}
:root[data-look="dracula"] { /* Dracula */
  --surface-100: #282a36;
  --surface-200: #21222c;
  --ink: #f8f8f2;
  --ink-muted: color-mix(in srgb, #6272a4 54%, white);
  --blue: #8be9fd;
  --pink: #ff79c6;
  --yellow: #f1fa8c;
  --green: #50fa7b;
}
:root[data-look="rosepine"] { /* Rosé Pine */
  --surface-100: #1f1d2e;
  --surface-200: #191724;
  --ink: #e0def4;
  --ink-muted: color-mix(in srgb, #908caa 84%, white);
  --blue: #9ccfd8;
  --pink: #eb6f92;
  --yellow: #f6c177;
  --green: color-mix(in srgb, #31748f 76%, white);
}
:root[data-look="gruvbox"] { /* Gruvbox dark */
  --surface-100: #282828;
  --surface-200: #1d2021;
  --ink: #ebdbb2;
  --ink-muted: color-mix(in srgb, #a89984 84%, white);
  --blue: #83a598;
  --pink: #d3869b;
  --yellow: #fabd2f;
  --green: #b8bb26;
}
:root[data-look="nord"] { /* Nord */
  --surface-100: #2e3440;
  --surface-200: #272c36;
  --ink: #eceff4;
  --ink-muted: color-mix(in srgb, #9da7ba 76%, white);
  --blue: #88c0d0;
  --pink: #b48ead;
  --yellow: #ebcb8b;
  --green: #a3be8c;
}
:root[data-look="kanagawa"] { /* Kanagawa */
  --surface-100: #1f1f28;
  --surface-200: #16161d;
  --ink: #dcd7ba;
  --ink-muted: color-mix(in srgb, #727169 66%, white);
  --blue: #7e9cd8;
  --pink: #d27e99;
  --yellow: #e6c384;
  --green: #98bb6c;
}
:root[data-look="onedark"] { /* One Dark */
  --surface-100: #282c34;
  --surface-200: #21252b;
  --ink: color-mix(in srgb, #abb2bf 74%, white);
  --ink-muted: color-mix(in srgb, #7f848e 64%, white);
  --blue: #61afef;
  --pink: #e06c75;
  --yellow: #e5c07b;
  --green: #98c379;
}
:root[data-look="latte"] { /* Catppuccin Latte */
  --surface-100: #eff1f5;
  --surface-200: #e6e9ef;
  --ink: color-mix(in srgb, #4c4f69 60%, black);
  --ink-muted: color-mix(in srgb, #6c6f85 84%, black);
  --blue: color-mix(in srgb, #1e66f5 82%, black);
  --blue-title: #1e66f5;
  --pink: color-mix(in srgb, #ea76cb 60%, black);
  --pink-title: #ea76cb;
  --yellow: color-mix(in srgb, #df8e1d 60%, black);
  --yellow-title: #df8e1d;
  --green: color-mix(in srgb, #40a02b 68%, black);
  --green-title: #40a02b;
}
:root[data-look="rosepine-dawn"] { /* Rosé Pine Dawn */
  --surface-100: #faf4ed;
  --surface-200: #f2e9e1;
  --ink: color-mix(in srgb, #575279 58%, black);
  --ink-muted: color-mix(in srgb, #797593 80%, black);
  --blue: color-mix(in srgb, #56949f 70%, black);
  --blue-title: #56949f;
  --pink: color-mix(in srgb, #b4637a 78%, black);
  --pink-title: #b4637a;
  --yellow: color-mix(in srgb, #ea9d34 58%, black);
  --yellow-title: #ea9d34;
  --green: color-mix(in srgb, #286983 96%, black);
  --green-title: #286983;
}
:root[data-look="solarized-light"] { /* Solarized light */
  --surface-100: #fdf6e3;
  --surface-200: #eee8d5;
  --ink: color-mix(in srgb, #586e75 46%, black);
  --ink-muted: color-mix(in srgb, #839496 66%, black);
  --blue: color-mix(in srgb, #268bd2 74%, black);
  --blue-title: #268bd2;
  --pink: color-mix(in srgb, #d33682 80%, black);
  --pink-title: #d33682;
  --yellow: color-mix(in srgb, #b58900 68%, black);
  --yellow-title: #b58900;
  --green: color-mix(in srgb, #859900 68%, black);
  --green-title: #859900;
}
:root[data-look="gruvbox-light"] { /* Gruvbox light */
  --surface-100: #fbf1c7;
  --surface-200: #ebdbb2;
  --ink: color-mix(in srgb, #3c3836 76%, black);
  --ink-muted: color-mix(in srgb, #7c6f64 82%, black);
  --blue: color-mix(in srgb, #076678 98%, black);
  --blue-title: #076678;
  --pink: #8f3f71;
  --pink-title: #8f3f71;
  --yellow: color-mix(in srgb, #b57614 72%, black);
  --yellow-title: #b57614;
  --green: color-mix(in srgb, #79740e 82%, black);
  --green-title: #79740e;
}
:root[data-look="github-light"] { /* GitHub light */
  --surface-100: #ffffff;
  --surface-200: #eff2f5;
  --ink: #1f2328;
  --ink-muted: #59636e;
  --blue: color-mix(in srgb, #0969da 92%, black);
  --blue-title: #0969da;
  --pink: color-mix(in srgb, #bf3989 90%, black);
  --pink-title: #bf3989;
  --yellow: color-mix(in srgb, #9a6700 88%, black);
  --yellow-title: #9a6700;
  --green: color-mix(in srgb, #1a7f37 90%, black);
  --green-title: #1a7f37;
}
:root[data-look="frappe"] { /* Catppuccin Frappé */
  --surface-100: #303446;
  --surface-200: #292c3c;
  --ink: #c6d0f5;
  --ink-muted: color-mix(in srgb, #a5adce 86%, white);
  --blue: #8caaee;
  --pink: #f4b8e4;
  --yellow: #e5c890;
  --green: #a6d189;
}
:root[data-look="macchiato"] { /* Catppuccin Macchiato */
  --surface-100: #24273a;
  --surface-200: #1e2030;
  --ink: #cad3f5;
  --ink-muted: #a5adcb;
  --blue: #8aadf4;
  --pink: #f5bde6;
  --yellow: #eed49f;
  --green: #a6da95;
}
:root[data-look="everforest"] { /* Everforest dark */
  --surface-100: #2d353b;
  --surface-200: #232a2e;
  --ink: color-mix(in srgb, #d3c6aa 84%, white);
  --ink-muted: color-mix(in srgb, #859289 64%, white);
  --blue: #7fbbb3;
  --pink: #d699b6;
  --yellow: #dbbc7f;
  --green: #a7c080;
}
:root[data-look="ayu-dark"] { /* Ayu dark */
  --surface-100: #0d1017;
  --surface-200: #0b0e14;
  --ink: #bfbdb6;
  --ink-muted: color-mix(in srgb, #636a76 72%, white);
  --blue: #59c2ff;
  --pink: #f07178;
  --yellow: #e6b450;
  --green: #aad94c;
}
:root[data-look="monokai"] { /* Monokai */
  --surface-100: #272822;
  --surface-200: #1e1f1c;
  --ink: #f8f8f2;
  --ink-muted: color-mix(in srgb, #75715e 60%, white);
  --blue: #66d9ef;
  --pink: color-mix(in srgb, #f92672 74%, white);
  --yellow: #e6db74;
  --green: #a6e22e;
}
:root[data-look="everforest-light"] { /* Everforest light */
  --surface-100: #fdf6e3;
  --surface-200: #efebd4;
  --ink: color-mix(in srgb, #5c6a72 50%, black);
  --ink-muted: color-mix(in srgb, #939f91 62%, black);
  --blue: color-mix(in srgb, #3a94c5 70%, black);
  --blue-title: #3a94c5;
  --pink: color-mix(in srgb, #df69ba 66%, black);
  --pink-title: #df69ba;
  --yellow: color-mix(in srgb, #dfa000 56%, black);
  --yellow-title: #dfa000;
  --green: color-mix(in srgb, #8da101 64%, black);
  --green-title: #8da101;
}
:root[data-look="ayu-light"] { /* Ayu light */
  --surface-100: #fcfcfc;
  --surface-200: #f3f4f5;
  --ink: color-mix(in srgb, #5c6166 56%, black);
  --ink-muted: color-mix(in srgb, #8a9199 68%, black);
  --blue: color-mix(in srgb, #399ee6 66%, black);
  --blue-title: #399ee6;
  --pink: color-mix(in srgb, #f07171 66%, black);
  --pink-title: #f07171;
  --yellow: color-mix(in srgb, #f2ae49 54%, black);
  --yellow-title: #f2ae49;
  --green: color-mix(in srgb, #86b300 62%, black);
  --green-title: #86b300;
}
:root[data-look="kanagawa-lotus"] { /* Kanagawa Lotus */
  --surface-100: #f2ecbc;
  --surface-200: #e5ddb0;
  --ink: color-mix(in srgb, #545464 52%, black);
  --ink-muted: color-mix(in srgb, #8a8980 66%, black);
  --blue: color-mix(in srgb, #4d699b 86%, black);
  --blue-title: #4d699b;
  --pink: color-mix(in srgb, #b35b79 76%, black);
  --pink-title: #b35b79;
  --yellow: color-mix(in srgb, #77713f 82%, black);
  --yellow-title: #77713f;
  --green: color-mix(in srgb, #6f894e 70%, black);
  --green-title: #6f894e;
}
/* Gear: El Jefe's own looks after kinds of equipment, not after any one
   machine: an amber screen, a black studio desk with orange, a beige
   drum machine and a pastel pocket synth. The same rules as the editor
   themes above. */
:root[data-look="amber"] { /* Amber screen */
  --surface-100: #140d03;
  --surface-200: #0c0802;
  --ink: #ffc14d;
  --ink-muted: color-mix(in srgb, #b88a3a 98%, white);
  --blue: #ffb000;
  --pink: #ff7a33;
  --yellow: #ffe08a;
  --green: #d9a441;
}
:root[data-look="studio"] { /* Studio black */
  --surface-100: #171717;
  --surface-200: #0f0f0f;
  --ink: #ededed;
  --ink-muted: #9a9a9a;
  --blue: #ff7a1a;
  --pink: #ff4d5e;
  --yellow: #ffc83d;
  --green: #3fd38d;
}
:root[data-look="beige"] { /* Beige machine */
  --surface-100: #e8e1cf;
  --surface-200: #d8cfb7;
  --ink: color-mix(in srgb, #2e2a24 90%, black);
  --ink-muted: color-mix(in srgb, #6b6253 86%, black);
  --blue: color-mix(in srgb, #e0601f 64%, black);
  --blue-title: #e0601f;
  --pink: color-mix(in srgb, #c8323c 80%, black);
  --pink-title: #c8323c;
  --yellow: color-mix(in srgb, #d29a16 52%, black);
  --yellow-title: #d29a16;
  --green: color-mix(in srgb, #4d8a52 68%, black);
  --green-title: #4d8a52;
}
:root[data-look="pastel"] { /* Pastel pocket */
  --surface-100: #f5f2ee;
  --surface-200: #e8e3dc;
  --ink: #2b2b33;
  --ink-muted: color-mix(in srgb, #6c6a75 88%, black);
  --blue: color-mix(in srgb, #6f8cff 64%, black);
  --blue-title: #6f8cff;
  --pink: color-mix(in srgb, #ff7eb6 56%, black);
  --pink-title: #ff7eb6;
  --yellow: color-mix(in srgb, #f5b83d 48%, black);
  --yellow-title: #f5b83d;
  --green: color-mix(in srgb, #47c58e 54%, black);
  --green-title: #47c58e;
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::selection { background: var(--pink); color: var(--pink-bg); }

/* Every size below is in rem, so the whole UI scales with the window width. */
html { font-size: clamp(9px, 0.95vw, 26px); }

body {
  margin: 0;
  background: var(--surface-100);
  color: var(--ink);
  font: 1rem/1.3 var(--font-sans);
}

/* Chassis */
.console {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0.833rem;
  background: var(--surface-100);
}

h1, h2 { margin: 0; }
/* The name is a neon title, the voice of the brand's wordmark: heavy italic,
   each letter filled with the ground of a tone and outlined with its colour.
   The four letters take the four tones, in the order of the wordmark and
   then green. */
h1 {
  font-size: 1.75rem;
  font-style: italic;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
}
h1 b {
  font-weight: inherit;
  color: var(--fill);
  -webkit-text-stroke: max(var(--stroke-line), 0.083em) var(--tone);
  paint-order: stroke fill;
}
h1 b:nth-of-type(1) { --tone: var(--blue); --fill: var(--blue-title); }
h1 b:nth-of-type(2) { --tone: var(--pink); --fill: var(--pink-title); }
h1 b:nth-of-type(3) { --tone: var(--yellow); --fill: var(--yellow-title); }
h1 b:nth-of-type(4) { --tone: var(--green); --fill: var(--green-title); }
/* what it is, as a label: upright, never in the neon voice */
h1 span {
  margin-left: 0.25rem;
  color: var(--ink-muted);
  font-size: 0.833rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0;
}
h2 { font-size: 1rem; font-weight: 600; }

label, .caption {
  color: var(--ink-muted);
  font-size: 0.917rem;
}
/* a label of a group of controls: small and quiet, in sentence case */
.caption { font-size: 0.833rem; font-weight: 500; }
label { display: flex; align-items: center; gap: 0.5rem; }

/* The plain controls. (In a layer of their own, below everything else: what
   is written for a part of the app still wins over them as before, and so do
   Dockview's own styles for its tabs and buttons.) */
@layer base {
  /* Quiet rounded controls with a hairline edge, in the shapes of the panels'
     own tabs and menus. Text boxes and menus are wells, a shade fainter. */
  button, select, input[type="number"], input[type="text"] {
    background: var(--border);
    color: var(--ink);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-control);
    padding: 3px 0.667rem;
    font: inherit;
    font-weight: 500;
  }
  :is(select, input[type="number"], input[type="text"]) { background: var(--well); }
  :is(select, input[type="number"], input[type="text"]):hover { border-color: var(--border-strong); }
  button { cursor: pointer; }
  button:hover { background: var(--border-strong); }
  button:disabled { opacity: 0.45; cursor: default; }
  button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, .knob:focus-visible {
    outline: var(--stroke-line) solid var(--focus);
    outline-offset: 1px;
  }
  input[type="range"], input[type="checkbox"] { accent-color: var(--accent); }
  /* Selected, or a view switched on: tinted with the accent. (What is lit
     because it sounds, plays, mutes or records is filled with its colour
     instead: see the transport, the mixer and the steps.) */
  button[aria-pressed="true"] {
    background: color-mix(in srgb, var(--accent) 20%, transparent);
    border-color: color-mix(in srgb, var(--accent) 55%, transparent);
    color: var(--accent);
  }
  button[aria-pressed="true"]:hover { background: color-mix(in srgb, var(--accent) 28%, transparent); }
  /* (with more contrast, filled) */
  :root[data-contrast="more"] button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
}

/* Readouts are yellow on its ground, like a price on
   the brand's menu. Longer text sits in a plain well. */
.lcd {
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}
pre.lcd, #cheats-status { background: var(--surface-100); color: var(--ink); }
pre, code { font-family: var(--font-mono); }

/* Transport */
.transport { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.667rem; }
/* a row of the top bar; .push sends what follows to the right */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.bar h1 { margin-right: 0.5rem; }
.push { margin-left: auto; }
/* the menu of things that are rarely needed */
.menu { position: relative; }
.menu summary {
  list-style: none;
  cursor: pointer;
  padding: 3px 0.667rem;
  background: var(--border);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  font-weight: 500;
}
.menu summary:hover { background: var(--border-strong); }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: var(--accent); color: var(--on-accent); }
.menu-body {
  position: absolute;
  top: calc(100% + 0.333rem);
  right: 0;
  z-index: 20;
  display: grid;
  gap: 0.5rem;
  min-width: 17rem;
  padding: 0.833rem;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.3);
}
.menu-body label { justify-content: space-between; }
.menu-body .group > * { flex: 1; }
.menu-body .caption:not(:first-child) { margin-top: 0.333rem; }
#sample-url { min-width: 0; }
.menu-body .group > #sample-url-add { flex: 0 0 auto; }
.sample-list { display: grid; gap: 0.25rem; max-height: 9rem; overflow: auto; }
.sample-list:empty { display: none; }
.sample { display: flex; align-items: center; gap: 0.5rem; font-size: 0.917rem; }
.sample span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sample button { padding: 0 0.417rem; }
.sample .song-open { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
#undo, #redo { width: 2.4rem; padding: 3px 0; font-size: 1.1rem; line-height: 1; }
.group { display: flex; align-items: center; gap: 0.5rem; }
.round { padding: 0.333rem 1rem; }
/* Play and Rec are tinted while they wait and filled while they run, in
   both themes alike */
.round.play { background: var(--green-bg); color: var(--green); }
.playing .round.play { background: var(--green); color: var(--green-bg); }
.round:is(.play, .rec):hover { filter: brightness(1.12); }
.transport-keys { gap: 0.25rem; }
#pause[aria-pressed="true"] { background: var(--warn); color: var(--on-warn); }
.round.rec { background: var(--pink-bg); color: var(--pink); }
.round.rec[aria-pressed="true"] { background: var(--pink); color: var(--pink-bg); }
.bpm-lcd { display: flex; align-items: center; gap: 0.5rem; padding: 0 0.667rem; }
.bpm-lcd label { color: inherit; opacity: 0.7; }
.bpm-lcd input {
  width: 5.833rem;
  background: none;
  border: 0;
  color: inherit;
  font-size: 1.333rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
#loop button { width: 2.333rem; padding: 3px 0; }
#loop button[aria-pressed="true"] { background: var(--time); color: var(--on-time); }
/* Scenes: a dot marks one with patterns in it, a ring the one a song is playing */
#scenes { gap: 0.25rem; }
.scene { position: relative; width: 2rem; padding: 3px 0; font-weight: 600; }
.scene.used::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 0.333rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: currentColor;
}
.scene.live { outline: var(--stroke-line) solid var(--time); outline-offset: 1px; }
/* waiting for the next bar */
.scene.queued { animation: queued 0.4s steps(2, jump-none) infinite; }
@keyframes queued { from { background: var(--border); } to { background: var(--time); color: var(--on-time); } }
/* no blinking for those who ask for less motion: it is outlined instead */
@media (prefers-reduced-motion: reduce) {
  .scene.queued { animation: none; outline: var(--stroke-line) dashed var(--time); outline-offset: 1px; }
}
#scene-tempo { padding: 0 0.333rem; font-size: 0.75rem; }
/* in a readout: no fill of its own until it is pointed at or on */
#scene-tempo { background: transparent; color: inherit; }
#scene-tempo:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
#scene-tempo[aria-pressed="true"] { background: var(--yellow); color: var(--yellow-bg); }
#perform button { padding: 2px 0; touch-action: none; }
#perform button[aria-pressed="true"] { background: var(--time); color: var(--on-time); }
#play-tools select { max-width: 7rem; }
#chain { width: 8rem; font-family: var(--font-mono); letter-spacing: 0.1em; }
/* the clip order of a channel or of the drums */
.clip-field { display: inline-flex; align-items: center; gap: 2px; }
.clip-order { width: 5.5rem; font-family: var(--font-mono); letter-spacing: 0.08em; }
.clip-order:not(:placeholder-shown) { border-color: var(--accent); }
.clip-add { padding: 0 0.4em; }
/* where the song is: bar . beat */
.pos-lcd {
  min-width: 4.5rem;
  padding: 1px 0.667rem;
  font-size: 1.083rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}
/* the song as a row of blocks, each as wide as its scene lasts */
.arrange-row { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0.25rem; min-height: 0; }
/* The arrangement when it is low: a position bar (see renderPosbar) */
.arrange-row.small > :not(#posbar) { display: none !important; }
.posbar { display: flex; align-items: center; min-height: 2rem; padding: 0.25rem 0.5rem; }
.posbar[hidden] { display: none; }
.posbar-track { position: relative; display: flex; flex: 1; height: 1.75rem; border-radius: 6px; overflow: hidden; cursor: pointer; background: var(--surface-100); }
.posbar-part {
  display: flex; align-items: center; padding-left: 0.3rem; min-width: 0; overflow: hidden;
  font: 0.7rem var(--font-mono); color: var(--ink-muted); white-space: nowrap;
  border-left: 1px solid var(--line); background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.posbar-part:nth-child(even) { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.posbar-head { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); pointer-events: none; }
/* The mixer when it is low: a meter bridge (see renderBridge) */
.mixer.small > :not(#bridge) { display: none !important; }
.bridge { display: flex; align-items: stretch; gap: 0.75rem; min-height: 0; overflow-x: auto; padding: 0.25rem; }
.bridge[hidden] { display: none; }
.bridge-group { display: flex; gap: 0.2rem; }
.bridge-cell, .bridge-master { display: grid; grid-template-rows: 1fr auto auto; justify-items: center; gap: 0.15rem; min-width: 1.9rem; }
.bridge-meter { position: relative; width: 1.9rem; min-height: 2rem; }
.bridge-meter .meter { inset: 0 0.65rem; }
.bridge-name { font: 600 0.7rem var(--font-mono); padding: 0 0.15rem; min-height: 1.25rem; max-width: 2.6rem; overflow: hidden; text-overflow: ellipsis; }
.bridge-cell.selected .bridge-name { color: var(--accent); }
.bridge-cell.muted .bridge-meter { opacity: 0.35; }
.bridge-switches { display: flex; gap: 1px; }
.bridge-switches button { min-width: 0; width: 0.95rem; height: 1.1rem; padding: 0; font-size: 0.6rem; }
.bridge-master { min-width: 5rem; padding-left: 0.5rem; border-left: 1px solid var(--line); }
.bridge-fader { width: 4.5rem; }
.bridge-master .bridge-name { max-width: none; }
.arrange-tools { display: flex; align-items: center; gap: 0.25rem; }
/* The arrangement: a name and a lane for each channel and the drums, under
   a ruler of bars. --bar-w is the width of a bar, --bars how many are shown. */
.arrange {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: 6.5rem calc(var(--bars) * var(--bar-w));
  /* the ruler, then the lanes sharing the height that is left: between
     a size still easy to hit and twice that (scrolling only below it) */
  --lane-min: 1.25rem;
  grid-template-rows: 1.25rem;
  grid-auto-rows: clamp(var(--lane-min), calc((100% - 1.25rem - var(--lanes, 1) * 2px) / var(--lanes, 1)), calc(var(--lane-min) * 2));
  align-content: start;
  gap: 2px 0;
  font-size: 0.833rem;
}
.arrange-name {
  position: sticky; left: 0; z-index: 2;
  min-width: 0; padding: 0 0.4rem; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--surface-200); border-radius: 0; font-size: 0.75rem;
}
.arrange-ruler { position: relative; cursor: pointer; border-bottom: 1px solid var(--border); }
.arrange-ruler span { position: absolute; left: calc(var(--at) * var(--bar-w)); top: 0.2rem; padding-left: 2px; border-left: 1px solid var(--border-strong); color: var(--ink-muted); font-size: 0.667rem; }
.arrange-lane {
  position: relative;
  background: repeating-linear-gradient(90deg, var(--well) 0 calc(var(--bar-w) - 1px), var(--border) calc(var(--bar-w) - 1px) var(--bar-w));
  border-radius: 3px;
  cursor: copy;
}
.arrange-block {
  position: absolute; top: 1px; bottom: 1px;
  left: calc(var(--at) * var(--bar-w)); width: calc(var(--len) * var(--bar-w) - 1px);
  display: flex; align-items: center; padding-left: 4px; overflow: hidden;
  border-radius: 3px; cursor: grab; touch-action: none; user-select: none;
  background: color-mix(in srgb, var(--clip, var(--accent)) 70%, var(--surface-200)); color: var(--on-accent); font-weight: 700;
}
.arrange-block.empty { background: var(--border-strong); color: var(--ink-muted); }
.arrange-edge { position: absolute; right: 0; top: 0; bottom: 0; width: 6px; cursor: ew-resize; }
.arrange-pos { position: absolute; top: 0; bottom: 0; left: calc(6.5rem + var(--at) * var(--bar-w)); width: 2px; background: var(--ink); pointer-events: none; z-index: 3; }
.arrange-pos[hidden] { display: none; }
/* clip colours, by row (as the launcher's) */
[data-clip="0"] { --clip: var(--blue); } [data-clip="1"] { --clip: var(--pink); } [data-clip="2"] { --clip: var(--yellow); } [data-clip="3"] { --clip: var(--green); }
[data-clip="4"] { --clip: var(--accent); } [data-clip="5"] { --clip: var(--time); } [data-clip="6"] { --clip: var(--go); } [data-clip="7"] { --clip: var(--rec); }
/* The clip launcher: ▶ and a cell for each column, per row */
.launcher {
  display: grid;
  grid-template-columns: 3.2rem repeat(var(--cols), minmax(3rem, 1fr));
  grid-auto-rows: 1.75rem;
  gap: 3px;
  padding: 0.5rem;
  overflow: auto;
  font-size: 0.75rem;
}
.launch-head { padding: 0 0.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.75rem; }
.launch-row { padding: 0; font-size: 0.75rem; }
.launch-row.on-screen { box-shadow: inset 0 0 0 1px var(--accent); }
.launch-cell { padding: 0; border-radius: 4px; background: var(--well); font-weight: 700; }
.launch-cell.filled { background: color-mix(in srgb, var(--clip) 45%, var(--surface-200)); color: var(--ink); }
.launch-cell.playing { background: var(--clip); color: var(--on-accent); box-shadow: inset 0 0 0 2px var(--ink); }
:root:not(.docked) .launcher { display: none; }
.launch-back { padding: 0; font-size: 0.917rem; }
.launch-stop { padding: 0; border-radius: 4px; font-size: 0.667rem; color: var(--ink-muted); }
/* The launcher when small: scene pads (see scenePads) */
.launcher.small { grid-template-columns: repeat(auto-fill, minmax(3.5rem, 1fr)); grid-auto-rows: minmax(2.5rem, 1fr); align-content: start; }
.scene-pad { padding: 0; border-radius: 8px; font-size: 1.1rem; font-weight: 800; background: color-mix(in srgb, var(--clip) 45%, var(--surface-200)); color: var(--ink); }
.scene-pad.playing { background: var(--clip); color: var(--on-accent); box-shadow: inset 0 0 0 2px var(--ink); }
.scene-pad.back { background: var(--surface-200); }
.launch-stop.stopped { background: var(--rec); color: var(--on-rec); }
/* a lane that a launched clip plays in place of */
.arrange-lane.overridden { opacity: 0.4; }
.tools { gap: 0.167rem; }
.tools button { padding: 1px 0.5rem; }
/* the rows of labelled tool groups above the sequencers */
.tools-row { gap: 0.333rem 1.333rem; }
.tools-row > .group { gap: 0.417rem; }
.tools-row label { font-size: 0.833rem; }
#length { margin-left: auto; }
#length ~ * { margin-left: 0; }
#side { gap: 0; }
#side button { border-radius: 0 var(--radius-control) var(--radius-control) 0; }
#side button:first-child { border-radius: var(--radius-control) 0 0 var(--radius-control); }
#midi-in.live { background: var(--on-go); color: var(--go); }
/* MIDI learn: what can be taught is outlined; solid if a controller already
   moves it, highlighted while it waits for one to be moved */
.midi-learn [data-learn] { outline: 1px dashed var(--time); outline-offset: 2px; cursor: crosshair; }
.midi-learn [data-learn].mapped { outline-style: solid; }
.midi-learn [data-learn].armed { outline: 3px solid var(--warn); }
#status { color: var(--ink-muted); font-size: 0.917rem; }
#status.error { padding: 1px 0.5rem; border-radius: var(--radius-sm); background: var(--on-rec); color: var(--rec); }

/* Panels */
.panel {
  margin-top: 0.5rem;
  padding: 0.667rem;
  background: var(--surface-200);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

/* Mixer: one strip per channel plus a master strip */
.mixer {
  display: flex;
  gap: 0.333rem;
  /* keeps its height: the sound panel below is what gives way and scrolls */
  flex: 0 0 auto;
  min-height: 0;
  overflow: auto;
  padding-bottom: 0.333rem;
}
.channels { display: flex; gap: 0.333rem; }
.strip {
  flex: 0 0 6.5rem;
  width: 6.5rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.417rem;
  padding: 0.417rem 0.417rem 0.5rem;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}
.strip.master { flex: 0 0 8rem; width: 8rem; background: var(--border); }
.strip.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.strip[hidden] { display: none; }
.strip.muted .fader { opacity: 0.45; }
.strip-head {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.333rem;
  cursor: pointer;
}
.strip.master .strip-head { cursor: default; }
/* the safety limiter: on (tinted), off (plain), and lit while it turns down */
.limiter { padding: 0 0.417rem; font-size: 0.75rem; }
.limiter.acting, .limiter.acting:hover { background: var(--warn); border-color: var(--warn); color: var(--on-warn); }
.strip-head .num { color: var(--ink-muted); }
.strip-head .id {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.917rem;
}
.strip.selected .strip-head .id { color: var(--accent); }
.strip-head .tag { color: var(--ink-muted); font-size: 0.833rem; }

.switches { display: flex; gap: 0.167rem; }
.switches button { width: 1.333rem; padding: 1px 0; font-size: 0.833rem; font-weight: 600; }
.strip .code {
  width: 100%;
  padding: 1px 3px;
  font: 0.75rem var(--font-mono);
}
.group-pick { color: var(--ink-soft); }
.group-pick.set { background: var(--on-warn); color: var(--warn); }
#groups { align-items: center; }
#groups .caption { flex: 0 0 auto; }
.mute[aria-pressed="true"] { background: var(--warn); color: var(--on-warn); }
.solo[aria-pressed="true"] { background: var(--go); color: var(--on-go); }

/* Fader on top of its level meter. The meter is three flat bands, green,
   yellow and pink: the colours up to the current level and their grounds
   above it. At the top the pink turns to ink and stays so for a moment. */
.fader { position: relative; flex-shrink: 0; width: 2.333rem; height: 7rem; }
.strip.master .fader { margin-top: auto; }
.meter {
  position: absolute;
  inset: 0 0.75rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  /* (the lit bands also show through the edge, round the unlit ones) */
  --top: var(--pink);
  background: linear-gradient(to top, var(--green) 0 60%, var(--yellow) 0 85%, var(--top) 0);
}
.meter-off {
  position: absolute;
  inset: 0 0 auto;
  height: calc((1 - var(--level, 0)) * 100%);
  /* the same bands, drawn as tall as the whole meter */
  background: linear-gradient(to top, var(--green-bg) 0 60%, var(--yellow-bg) 0 85%, var(--pink-bg) 0)
    top / 100% calc(100% / max(0.001, 1 - var(--level, 0))) no-repeat;
}
.meter.peak { --top: var(--ink); }
.vfader {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  writing-mode: vertical-lr;
  direction: rtl;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: ns-resize;
}
.vfader::-webkit-slider-runnable-track { background: transparent; }
.vfader::-moz-range-track { background: transparent; }
.vfader::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 2.167rem;
  height: 0.583rem;
  background: var(--handle);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.45);
}
.vfader::-moz-range-thumb {
  width: 2.167rem;
  height: 0.583rem;
  background: var(--handle);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.45);
}
/* The other sliders: a thin trough with a square handle */
input[type="range"]:not(.vfader) {
  appearance: none;
  -webkit-appearance: none;
  height: 1.167rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]:not(.vfader)::-webkit-slider-runnable-track { height: 0.25rem; border-radius: 999px; background: var(--border-strong); }
input[type="range"]:not(.vfader)::-moz-range-track { height: 0.25rem; border-radius: 999px; background: var(--border-strong); }
input[type="range"]:not(.vfader)::-moz-range-progress { height: 0.25rem; border-radius: 999px; background: var(--accent); }
input[type="range"]:not(.vfader)::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 0.917rem;
  height: 0.917rem;
  margin-top: -0.333rem;
  background: var(--handle);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.45);
}
input[type="range"]:not(.vfader)::-moz-range-thumb {
  width: 0.917rem;
  height: 0.917rem;
  background: var(--handle);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.45);
}
/* Beside the mixer: the output's scope and spectrum, undo and song files */
.strip.song-panel {
  /* the scopes are green, here and in the sound panel */
  --hue: var(--green);
  --hue-bg: var(--green-bg);
  flex: 1 1 0;
  width: auto;
  min-width: 14rem;
  align-items: stretch;
}
.song-panel .strip-head { cursor: default; }
.song-panel .strip-head .id { color: var(--hue); }
/* (The two canvases are laid over the box, which has the height the mixer
   gives it: they never ask for a size of their own. Their pixel size is set
   from the size they are shown at, and if that fed back into the layout the
   mixer could grow, as it did on high-density screens.) */
.scopes { position: relative; flex: 1; min-height: 3rem; }
.scopes .scope { position: absolute; top: 0; width: calc(50% - 0.208rem); height: 100%; }
.scopes .scope:first-child { left: 0; }
.scopes .scope:last-child { right: 0; }
/* Output when low: its level and the effect buttons as pads, in place of the scopes */
.out-level { display: none; }
.song-panel.small { display: grid; grid-template-columns: 1.6rem 1fr; grid-template-rows: 1fr auto; gap: 0.4rem; }
.song-panel.small .scopes { display: none; }
.song-panel.small .out-level { display: block; position: relative; grid-row: 1 / span 2; }
.song-panel.small .out-level .meter { inset: 0 0.4rem; }
.song-panel.small #perform { display: grid; grid-template-columns: repeat(auto-fill, minmax(3rem, 1fr)); gap: 0.25rem; align-content: start; }
.song-panel.small #perform button { min-height: 2.25rem; font-size: 0.95rem; }
.song-tools { display: flex; gap: 0.333rem; }
.song-tools button { flex: 1; padding: 2px 0.333rem; font-size: 0.833rem; white-space: nowrap; }
.xfade { width: 100%; font-weight: 600; }
.xfade input { flex: 1; min-width: 0; }

.pad {
  width: 100%;
  padding: 3px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  font-size: 0.833rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  background: var(--border);
  touch-action: manipulation;
}
.pad small { color: var(--ink-soft); font-weight: 400; }
.pad { -webkit-touch-callout: none; } /* (held: the menu of its row) */
.pad.hit, .pad.hit small { background: var(--accent); color: var(--on-accent); }

/* Sound panel: modules for the selected channel or drum. Each has a title,
   a display of what it does and its knobs, all in the hue of its kind. */
.synth { flex: 0 1 auto; min-height: 0; overflow: auto; padding: 0.5rem; }
.modules, .extras { display: flex; flex-wrap: wrap; gap: 0.417rem; }
/* the pages of the sound panel */
.pages { gap: 0.25rem; margin-bottom: 0.417rem; }
.pages button { padding: 1px 0.75rem; font-size: 0.917rem; }
.module.off-page { display: none; }
/* on its own the sound panel shows every page */
.solo-sound .module.off-page { display: flex; }
.solo-sound .pages { display: none; }
.module {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.417rem;
  padding: 0.417rem 0.583rem 0.5rem;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}
/* One tone per page, so that what belongs together looks it: Source (and
   Pattern) blue, Shape pink, Motion green, Effects yellow. A module takes the
   tone of its page; one that is on no page (the extras) that of its kind. */
.module:is(.filter, .contour) { --hue: var(--pink); --hue-bg: var(--pink-bg); }
.module.mod { --hue: var(--green); --hue-bg: var(--green-bg); }
.module.fx { --hue: var(--yellow); --hue-bg: var(--yellow-bg); }
:is(.module, .pages button):is([data-page="source"], [data-page="pattern"]) { --hue: var(--blue); --hue-bg: var(--blue-bg); }
:is(.module, .pages button)[data-page="shape"] { --hue: var(--pink); --hue-bg: var(--pink-bg); }
:is(.module, .pages button)[data-page="motion"] { --hue: var(--green); --hue-bg: var(--green-bg); }
:is(.module, .pages button)[data-page="fx"] { --hue: var(--yellow); --hue-bg: var(--yellow-bg); }
/* the tabs of those pages: a dot of the page's tone, and the one shown
   tinted with it */
.pages button { display: inline-flex; align-items: center; gap: 0.417rem; }
.pages button:not([data-page="all"], [data-page="song"])::before {
  content: "";
  width: 0.5rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--hue);
}
.pages button:not([data-page="all"], [data-page="song"])[aria-pressed="true"] {
  background: color-mix(in srgb, var(--hue) 20%, transparent);
  border-color: color-mix(in srgb, var(--hue) 55%, transparent);
  color: var(--hue);
}
/* what belongs to the whole song has no neon */
.module.global { --hue: var(--ink); --hue-bg: var(--surface-200); background: var(--border); }
.module-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.333rem; min-height: 1.667rem; }
.module-head button { padding: 1px 0.5rem; font-size: 0.833rem; }
.module-head label { font-size: 0.75rem; gap: 0.25rem; }
/* modules made of rows of menus and text boxes */
.rows-module .fn-row { flex: 0 0 auto; }
.rows-module .fn-row button { padding: 1px 0.5rem; font-size: 0.833rem; }
.fn-row .pattern-text { flex: 1; width: auto; min-width: 12rem; }
.fn-row input[hidden] { display: none; }
/* typed notes play instead of the drawn ones */
.roll.typed #notes { opacity: 0.3; }
.drum-row.typed .steps { opacity: 0.3; }
/* the title, in the module's tone after a dot of it */
.module-head h3 {
  display: flex;
  align-items: center;
  gap: 0.417rem;
  margin: 0 auto 0 0;
  color: var(--hue);
  font-size: 0.833rem;
  font-weight: 600;
  white-space: nowrap;
}
.module-head h3::before {
  content: "";
  width: 0.5rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--hue);
}
.module select { max-width: 9rem; padding: 1px 3px; font-size: 0.833rem; }
.module-body { display: flex; align-items: flex-end; justify-content: space-around; gap: 0.417rem; }
.module-body:empty { display: none; }

.display {
  width: 100%;
  min-width: 7rem;
  height: 3.25rem;
  background: color-mix(in srgb, var(--hue-bg) 80%, transparent);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  /* faint centre line and quarter marks */
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--hue) 25%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, transparent calc(50% - 0.5px), color-mix(in srgb, var(--hue) 25%, transparent) 0 calc(50% + 0.5px), transparent 0);
  background-size: 25% 100%, 100% 100%;
}
.display polyline {
  fill: none;
  stroke: var(--hue);
  stroke-width: var(--stroke-line);
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.display polyline.dim { opacity: 0.45; stroke-dasharray: 3 3; }
.display.na polyline { opacity: 0.25; }

.ctl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 3rem;
  color: var(--ink-muted);
  font-size: 0.75rem;
  white-space: nowrap;
  transition: opacity 0.1s;
}
.ctl.na { opacity: 0.3; }
/* A thin ring lit in the module's tone from the knob's origin to its value,
   around a plain dial with a pointer. */
.knob {
  --angle: 0deg;
  --lo: 0;
  --hi: 0;
  --ring: var(--border-strong);
  --face: color-mix(in srgb, var(--ink) 9%, var(--surface-200));
  position: relative;
  width: 2.667rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--face) 76%, transparent 78%),
    conic-gradient(from 225deg,
      var(--ring) calc(var(--lo) * 270deg),
      var(--hue) 0 calc(var(--hi) * 270deg),
      var(--ring) 0 270deg,
      transparent 0);
  cursor: ns-resize;
  touch-action: none;
}
.knob::after {
  content: "";
  position: absolute;
  top: 18%;
  left: calc(50% - 1.5px);
  width: 3px;
  height: 32%;
  border-radius: 2px;
  /* dimmed while the knob is where it starts */
  background: var(--ink-muted);
  transform-origin: 50% 100%;
  transform: rotate(var(--angle));
}
.knob.active::after { background: var(--ink); }
/* A knob that is on a quick knob: a dot at its top left (a knob with
   locked steps has one at its top right) */
.ctl.quick-on { position: relative; }
.ctl.quick-on::before {
  content: "";
  position: absolute;
  top: 0;
  left: calc(50% - 1.333rem);
  width: 0.5rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
}
/* The Sound panel when it is small: only the quick knobs (see renderQuick) */
.synth.quick > :not(#quick) { display: none !important; }
.quick-view { display: flex; flex-direction: column; gap: 0.5rem; min-height: 0; overflow: auto; }
.quick-view[hidden] { display: none; }
.quick-head { display: flex; align-items: center; gap: 0.5rem; }
.quick-head button { min-width: 2.25rem; height: 2.25rem; font-size: 1.1rem; }
.quick-name { flex: 1; display: grid; text-align: center; line-height: 1.2; }
.quick-name b { color: var(--accent); }
.quick-name span { font: 0.75rem var(--font-mono); color: var(--ink-muted); }
.quick-knobs { display: grid; grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr)); gap: 0.75rem 0.5rem; align-content: start; }
.quick-knob { min-width: 0; }
.quick-knob .knob { width: 3.5rem; }
.quick-knob > span { color: var(--ink); font-weight: 600; white-space: normal; text-align: center; }
.quick-value { font: 0.7rem var(--font-mono); color: var(--ink-muted); white-space: normal; text-align: center; max-width: 7rem; }
/* Low and wide: the name and ‹ › at the left, the knobs in one row beside it */
.synth.quick { container-type: size; }
@container (min-aspect-ratio: 3 / 1) {
  .quick-view { flex-direction: row; align-items: center; }
  .quick-head { flex-direction: column; flex: none; width: 6rem; }
  .quick-head button { height: 1.75rem; }
  .quick-knobs { flex: 1; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(4.5rem, 1fr); }
}
/* Very low: smaller knobs, without the value under them (it shows on the knob, and while turning it) */
@container (max-height: 7rem) {
  .quick-knob .knob { width: 2.25rem; }
  .quick-value { display: none; }
  .quick-name span { display: none; }
}
/* A knob with locked steps */
.ctl.locked .knob::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 0.5rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--time);
}

.synth-title {
  --hue: var(--ink);
  --hue-bg: var(--surface-200);
  flex: 0 0 11rem;
  width: 11rem;
  justify-content: space-between;
  font-size: 1.167rem;
  font-weight: 600;
}
.synth-title .num { padding: 0 0.417rem; border-radius: var(--radius-sm); background: var(--blue-bg); color: var(--blue); }
/* The readout takes the height the module has left (the modules beside it
   set that), and never asks for more: a long text is cut off instead of
   making the row taller and moving everything below it. */
.synth-title .readout {
  flex: 1 1 0;
  min-height: calc(2.4em + 0.5rem); /* two whole lines */
  padding: 0.25rem 0.417rem;
  font-size: 0.833rem;
  font-weight: 400;
  line-height: 1.2;
  overflow: hidden;
  overflow-wrap: anywhere;
  /* Its text changes with every move of a knob, and without this each change
     lays out every module of the panel again. */
  contain: strict;
}
.synth-title button { font: inherit; font-size: 0.833rem; }
.synth-title select { min-width: 0; padding: 1px 3px; font-size: 0.833rem; }
#drum-tools .action-menu { max-width: 7rem; }

.fn-row { display: flex; gap: 0.333rem; align-items: center; flex: 1; }
.fn-row select, .fn-row input { min-width: 0; width: 9rem; padding: 1px 3px; font-size: 0.833rem; }
.fn-row input { font-family: var(--font-mono); }
.fn-row input:disabled { opacity: 0.4; }

/* Extras, while the sound panel is the only part shown: it then fills the
   screen. */
.extras { display: none; margin-top: 0.417rem; }
.solo-sound .synth { flex: 1 1 0; }
.solo-sound .extras { display: grid; grid-template-columns: 16rem minmax(0, 1fr) minmax(0, 1fr); }
.solo-sound .extras.for-drum { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem; }
.presets button { padding: 2px 0.333rem; font-size: 0.833rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scope { display: block; width: 100%; height: 4.5rem; background: var(--hue-bg); color: var(--hue); }
.code-box pre { flex: 1; min-height: 6rem; max-height: 14rem; overflow: auto; font-size: 0.917rem; }
.keys-box { grid-column: 1 / -1; }
.keyboard { position: relative; display: flex; height: 5.5rem; touch-action: none; user-select: none; }
.kb { padding: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm); touch-action: none; }
.kb.white {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--key-white);
  color: var(--key-black);
  border-color: var(--key-edge);
  font-size: 0.75rem;
}
.kb.white:hover { background: var(--key-white-hover); }
.kb.black {
  position: absolute;
  top: 0;
  width: 2%;
  height: 60%;
  transform: translateX(-50%);
  background: var(--key-black);
  border-color: var(--key-black);
}
.kb.black:hover { background: var(--key-black-hover); }
.kb.down, .kb.down:hover { background: var(--accent); }
.key.down, .key.black.down { background: var(--accent); color: var(--on-accent); }

/* Sequencer area: takes the height the panels above leave over and never
   shrinks below its minimum height. Holds the piano roll or the drum grid. */
.workspace { flex: 1 0 19rem; min-height: 0; display: flex; gap: 0.5rem; }
.seq, .drums { flex: 1 1 0; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 0.5rem; }
/* the rows above a sequencer: its title or tabs, then its tools */
.heads { display: flex; flex-direction: column; gap: 0.5rem; }
/* The drums: the tools, and to their right the place of Bars and Steps,
   kept whether or not they are there, so that nothing moves. */
.drum-heads { flex-direction: row; align-items: flex-start; }
.drum-heads #drum-tools { flex: 1 1 auto; min-width: 0; }
.drum-heads #drum-head { flex: none; min-width: 13rem; justify-content: flex-end; }
.roll-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.333rem 0.833rem; }
.roll-head h2 { margin-right: auto; }
.roll-head .hint { cursor: help; }
.roll-head select { padding: 1px 3px; font-size: 0.917rem; }
.made { min-width: 7rem; text-transform: none; }
.tab small { color: var(--ink-soft); }
.tab[aria-pressed="true"] small { color: inherit; opacity: 0.75; }
.tab.muted { opacity: 0.5; }

/* Drum machine: a row per drum */
.drum-rows {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  /* --fit-row: the height at which a whole number of rows fills the box (see fitDrumRows) */
  grid-auto-rows: var(--fit-row, minmax(1.333rem, 1fr));
  gap: 0.333rem;
  scroll-snap-type: y mandatory;
}
.drum-row { scroll-snap-align: start; }
.drum-row {
  display: grid;
  grid-template-columns: 7rem auto 6rem minmax(0, 1fr);
  gap: 0.417rem;
  align-items: center;
  min-height: 0;
}
.drum-row .pad { height: 100%; justify-content: center; padding: 0 0.25rem; font-size: 0.833rem; white-space: nowrap; overflow: hidden; }
.drum-row.selected .pad, .drum-row.selected .pad small { background: var(--on-accent); color: var(--accent); }
.drum-row.selected .pad.hit, .drum-row.selected .pad.hit small { background: var(--accent); color: var(--on-accent); }
.drum-row .switches { gap: 0.167rem; }
.drum-row .switches button { width: 1.5rem; font-size: 0.75rem; }
.drum-row .level { width: 100%; min-width: 0; }
.drum-row.muted .level { opacity: 0.45; }
/* a lane: more steps of the drum above, with its number in place of the pad */
.drum-row.lane .lane-name { justify-self: end; padding-right: 0.5rem; font-size: 0.75rem; color: var(--ink-muted); }
.drum-row.lane .lane-cut { width: 1.5rem; font-size: 0.75rem; padding: 0; }
.drum-row.lane .step { opacity: 0.85; }
/* the level sliders (and their gap in the lane below) switched off with Levels */
.hide-levels .drum-row { grid-template-columns: 7rem auto minmax(0, 1fr); }
.hide-levels .drum-row > :nth-child(3) { display: none; }
:root { --step-gap: 0.417rem; --bar-gap: 0.5rem; }
.steps { display: grid; gap: var(--step-gap); height: 100%; }
/* The steps (and the velocity lane under them) share their row equally,
   after the gap that starts each bar: in a grid of equal columns that gap
   would come out of the first step of the bar, which would look smaller. */
.steps, #drum-vel-steps { display: flex; }
.steps > .step, #drum-vel-steps > .vel-cell { flex: 1 1 0; min-width: 0; }
.step {
  min-width: 0;
  height: 100%;
  padding: 0;
  /* a finger drags across the steps to paint them, and holds one to change
     it: neither scrolls nor calls up the system's menu */
  touch-action: none;
  -webkit-touch-callout: none;
  /* its colours: lit, off, and what is written on it when lit */
  --step: var(--accent);
  --step-off: var(--border);
  --step-ink: var(--on-accent);
  background: var(--step-off);
  color: var(--step-ink);
  border-color: transparent;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  overflow: hidden;
}
.step.beat { --step-off: var(--border-strong); }
.step.bar-start { margin-left: var(--bar-gap); }
.step:not(.on):hover { background: color-mix(in srgb, var(--step) 30%, var(--step-off)); }
.step.on { background: var(--step); }
/* El Jefe's own themes: the steps are keys in the four tones, one for each
   beat of the bar, like those of a TR-808: dim while off, lit when on. The
   lane under them follows. (So the step that plays is outlined in ink: the
   yellow of the playhead would not show on the third beat.) */
:root:not([data-look]) :is(.step, .vel-cell) { --step: var(--blue); --step-ink: var(--blue-bg); }
:root:not([data-look]) :is(.step, .vel-cell)[data-beat="1"] { --step: var(--pink); --step-ink: var(--pink-bg); }
:root:not([data-look]) :is(.step, .vel-cell)[data-beat="2"] { --step: var(--yellow); --step-ink: var(--yellow-bg); }
:root:not([data-look]) :is(.step, .vel-cell)[data-beat="3"] { --step: var(--green); --step-ink: var(--green-bg); }
:root:not([data-look]) .step { --step-off: color-mix(in srgb, var(--step) 26%, var(--surface-100)); }
:root:not([data-look]) .step.playing { outline-color: var(--ink); }
.step.marked { font-size: 0.667rem; }
/* the menu of what a step does */
.step-menu {
  position: fixed;
  z-index: 60; /* (above the drum machine too) */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 0.333rem;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.3);
}
.step-menu[hidden] { display: none; }
.step-menu button { padding: 2px 0.5rem; font-size: 0.833rem; text-align: left; white-space: nowrap; }
.step-menu button:first-child { grid-column: 1 / -1; }
#steps { width: 4.5rem; }
.pattern-row { display: flex; align-items: center; gap: 0.5rem; flex: 1; }
.module-head input[type="number"], .fn-row input[type="number"] { width: 4rem; padding: 1px 3px; font-size: 0.833rem; }
.fn-row label { font-size: 0.75rem; gap: 0.25rem; }
/* a harder hit has a ring of the partner colour inside it */
.step.accent { box-shadow: inset 0 0 0 2px var(--step), inset 0 0 0 4px var(--step-ink); }
/* (an outline drawn inside: a border would make the step bigger as the playhead passes) */
.step.playing { outline: var(--stroke-line) solid var(--time); outline-offset: calc(-1 * var(--stroke-line)); }
.drum-row.muted .step.on { opacity: 0.4; }
.looping .step:not(.in-loop) { opacity: 0.35; }
/* Velocity lane of the selected drum, in the columns of the grid above */
.drum-vel { flex: 0 0 4.5rem; }
.drum-vel[hidden] { display: none; }
/* (the rows above scroll: both keep the room of a scrollbar, so that the lane's steps sit under theirs) */
.drum-rows, #drum-vel { scrollbar-gutter: stable; }
#drum-vel { overflow-y: hidden; }
.drum-vel .switches { visibility: hidden; }
.lane-tools { display: flex; gap: 0.167rem; width: 100%; min-width: 0; }
.lane-tools select { flex: 1; min-width: 0; padding: 1px 3px; font-size: 0.75rem; }
.lane-tools button { padding: 1px 0.333rem; font-size: 0.75rem; }
#lane-tools select { max-width: 11rem; }
/* locks: no line for a normal level, and steps that follow the knob are faint */
.locks .vel-cell::after { display: none; }
.vel-bar.free, .vel.free { opacity: 0.25; }
.vel-name {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  white-space: nowrap;
  color: var(--ink-muted);
  font-size: 0.833rem;
  font-variant-numeric: tabular-nums;
}
.vel-name small { font-size: 0.75rem; text-transform: none; white-space: nowrap; }
#drum-vel-steps { cursor: ns-resize; touch-action: none; user-select: none; }
.vel-cell { position: relative; height: 100%; background: var(--well); border-radius: var(--radius-sm); overflow: hidden; }
.vel-cell.bar-start { margin-left: var(--bar-gap); }
/* the normal level */
.vel-cell::after {
  content: "";
  position: absolute;
  inset: auto 0 66.67%;
  border-top: 1px dashed var(--border-strong);
}
.vel-bar { position: absolute; inset: auto 15% 0; background: var(--step, var(--accent)); border-radius: 2px 2px 0 0; }

/* Piano roll */
.roll {
  --row-h: 1rem;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  /* zoomed in, the grid is several times as wide as the roll, which scrolls */
  grid-template-columns: 3.5rem calc((100% - 3.5rem) * var(--zoom, 1));
  align-items: start;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}
.keys { position: sticky; left: 0; z-index: 3; }
.key {
  display: block;
  width: 100%;
  height: var(--row-h);
  padding: 0 0.333rem;
  border: 0;
  border-bottom: 1px solid var(--key-edge);
  border-radius: 0;
  background: var(--key-white);
  color: var(--key-black);
  font-size: 0.75rem;
  line-height: 1;
  text-align: right;
  touch-action: manipulation;
}
.key.black { background: var(--key-black); color: var(--key-white); border-bottom-color: var(--key-black-hover); }
.key:hover { background: var(--key-white-hover); }
.key.black:hover { background: var(--key-black-hover); }
.key.hit, .key.black.hit { background: var(--accent); color: var(--on-accent); }

.grid {
  --steps: 16;
  --bar: 16;
  --step-w: calc(100% / var(--steps));
  position: relative;
  overflow: hidden;
  cursor: crosshair;
  touch-action: pan-y;
  user-select: none;
}
/* the rows of the white keys are the wall, those of the black keys the panel */
.lane { height: var(--row-h); background: var(--surface-100); border-bottom: 1px solid color-mix(in srgb, var(--rule) 25%, transparent); }
.lane.black { background: var(--surface-200); }
.lane.c { border-bottom-color: var(--rule); }
.lane.out { filter: brightness(0.72); }
:root[data-theme="day"] .lane.out { filter: brightness(0.88); }
.lane.tonic { box-shadow: inset 3px 0 0 var(--accent); }
/* step, beat and bar lines */
.grid::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--rule) 2px, transparent 2px),
    linear-gradient(to right, color-mix(in srgb, var(--rule) 70%, transparent) 1px, transparent 1px),
    linear-gradient(to right, color-mix(in srgb, var(--rule) 25%, transparent) 1px, transparent 1px);
  background-size: calc(var(--step-w) * var(--bar)) 100%, calc(var(--step-w) * 4) 100%, var(--step-w) 100%;
}
/* the lines of a grid other than the sixteenths */
.grid.fine::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(to right, color-mix(in srgb, var(--time) 28%, transparent) 1px, transparent 1px);
  background-size: calc(var(--step-w) * var(--g)) 100%;
}
#notes { position: absolute; inset: 0; }
#grid-menu { max-width: 9rem; padding: 1px 3px; font-size: 0.917rem; }
/* Velocity lane: stays at the bottom of the roll while it scrolls */
.vel-label, .velocity {
  position: sticky;
  bottom: 0;
  z-index: 2;
  height: var(--vel-h, 2.5rem);
  background: var(--surface-200);
  border-top: 1px solid var(--line);
}
.vel-label {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  font-size: 0.75rem;
  cursor: help;
}
.vel-label #vel-value {
  position: relative;
  z-index: 1;
  padding: 0 0.25rem;
  background: var(--surface-200);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.vel-label { justify-content: flex-start; overflow: visible; left: 0; z-index: 4; }
/* The top edge of the label is the handle that resizes the lane */
.vel-grip {
  position: absolute;
  inset: -3px 0 auto;
  height: 0.667rem;
  cursor: row-resize;
  touch-action: none;
  border-top: 3px solid var(--border-strong);
}
.vel-grip:hover, .vel-grip:active { border-top-color: var(--accent); }
.velocity {
  --steps: 16;
  --step-w: calc(100% / var(--steps));
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
}
.vel {
  position: absolute;
  bottom: 0;
  left: calc(var(--s) * var(--step-w));
  width: max(3px, calc(var(--step-w) * 0.6));
  height: calc(var(--v) * 100%);
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  pointer-events: none;
}
.note, .playhead, .loop-zone {
  position: absolute;
  left: calc(var(--s) * var(--step-w));
  width: calc(var(--l, 1) * var(--step-w));
}
.note {
  top: calc(var(--r) * var(--row-h));
  height: var(--row-h);
  background: var(--accent);
  border: 1px solid color-mix(in srgb, var(--on-accent) 70%, transparent);
  border-radius: var(--radius-sm);
  cursor: grab;
}
/* Marks of a monophonic channel: an accent is outlined, a slide has a ramp
   on its left edge. */
.note.accent { box-shadow: inset 0 0 0 1px var(--accent), inset 0 0 0 3px var(--on-accent); }
.note.slide::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: min(0.75rem, 60%);
  background: var(--on-accent);
  clip-path: polygon(0 100%, 100% 0, 100% 100%);
}
.note.selected { outline: var(--stroke-line) solid var(--time); outline-offset: 1px; z-index: 1; filter: brightness(1.2); }
.marquee {
  position: absolute;
  background: color-mix(in srgb, var(--time) 15%, transparent);
  border: 1px dashed var(--time);
  pointer-events: none;
}
.marquee[hidden] { display: none; }
#note-menu, #zoom-menu { max-width: 7rem; padding: 1px 3px; font-size: 0.917rem; }
#mono-tools[hidden] { display: none; }
.note.ghost { background: var(--ink-muted); border: 0; opacity: 0.3; pointer-events: none; }
.grip { position: absolute; top: 0; right: 0; bottom: 0; width: min(0.5rem, 40%); cursor: ew-resize; }
.playhead, .loop-zone { top: 0; bottom: 0; pointer-events: none; }
.playhead { background: color-mix(in srgb, var(--time) 25%, transparent); border-left: 2px solid var(--time); }
.loop-zone { background: color-mix(in srgb, var(--time) 12%, transparent); outline: var(--stroke-line) solid var(--time); outline-offset: -2px; }

/* Strudel code */
.strudel { flex: 0 1 26vh; min-height: 0; display: flex; flex-direction: column; }
.strudel pre { flex: 1; min-height: 0; overflow: auto; }
/* Strudel's editor: its own colours, filling the panel */
.code-editor { flex: 1; min-height: 0; overflow: hidden; border-radius: var(--radius-control); border: 1px solid var(--line); }
.code-editor[hidden] { display: none; }
.code-editor .cm-editor { height: 100%; }
.code-editor .cm-scroller { overflow: auto; }
.hide-seq .strudel { flex: 1 1 0; }
.strudel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.667rem;
  margin-bottom: 0.5rem;
}
.strudel-head { justify-content: flex-end; } /* (the tab names the panel) */
.strudel a { color: var(--go); }
pre {
  margin: 0;
  padding: 0.667rem;
  overflow-x: auto;
  font-size: 1rem;
  line-height: 1.4;
}

/* Parts hidden by the Show buttons and the Synths | Drums switch. In the
   panels of the full layout the panels show and hide them, and the piano
   roll and the drums can be shown side by side. */
:root:not(.docked) :is(.hide-mixer .mixer, .hide-synth .synth, .hide-seq .workspace, .hide-code .strudel,
  .side-synth .drums, .side-drums .seq),
.side-synth #drum-channels, .side-drums #channels { display: none; }

/* Cheat sheet */
dialog {
  width: min(60rem, calc(100% - 2.667rem));
  max-height: 85vh;
  padding: 1.333rem;
  background: var(--surface-200);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
/* The theme maker: a colour well and its name for each colour */
dialog.maker { width: min(30rem, calc(100% - 2.667rem)); }
.maker-colours { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.5rem 1rem; margin: 0.75rem 0; }
.maker-colours label { display: flex; align-items: center; gap: 0.5rem; }
.maker-colours input[type="color"] { width: 2.75rem; height: 2.25rem; padding: 2px; border: 1px solid var(--hairline); border-radius: var(--radius-control); background: var(--well); }
.maker-check { display: flex; gap: 0.5rem; align-items: flex-start; margin-bottom: 0.75rem; color: var(--ink-muted); }
dialog::backdrop { background: color-mix(in srgb, var(--surface-100) 70%, transparent); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
dialog h3 {
  margin: 1.333rem 0 0.5rem;
  color: var(--ink-muted);
  font-size: 0.917rem;
}
dialog code { font-family: var(--font-mono); }
.cheat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.333rem;
  margin-bottom: 0.333rem;
}
.cheat[hidden] { display: none; }
.cheat-use {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  text-align: left;
}
.cheat-use:disabled { opacity: 0.45; }
.cheat code { overflow-wrap: anywhere; }
.cheat span { color: var(--ink-soft); }
.cheat-use[aria-pressed="true"] span { color: inherit; }
#cheats-tools { flex-wrap: wrap; margin-bottom: 0.5rem; }
#cheats-tools input { flex: 1; min-width: 8rem; }
#cheats-status { min-height: 1.4em; margin: 0 0 0.5rem; padding: 0.25rem 0.5rem; overflow-wrap: anywhere; font-family: var(--font-mono); }
#cheats-status:empty { visibility: hidden; }
#cheats-status.error { background: var(--on-rec); color: var(--rec); }

/* Import code */
#import-text {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0 0 0.5rem;
  padding: 0.5rem;
  resize: vertical;
  background: var(--surface-100);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 4px);
  font: 0.917rem/1.4 var(--font-mono);
}
#import-status { min-height: 1.4em; margin: 0.5rem 0; padding: 0.25rem 0.5rem; overflow-wrap: anywhere; font-family: var(--font-mono); }
#import-status:empty { visibility: hidden; }
#import-status.error { background: var(--on-rec); color: var(--rec); }
.import-report { margin: 0; padding-left: 1.25rem; color: var(--ink-soft); }
.import-report:empty { display: none; }

/* Touch screens: every control gets a finger-sized target. Mouse-driven
   screens keep the compact layout. */
@media (pointer: coarse) {
  html { font-size: clamp(11px, 0.95vw, 26px); }
  @layer base { /* (see the plain controls: not Dockview's buttons) */
    button, select, input[type="number"], input[type="text"] { min-height: 40px; }
  }
  .transport { gap: 8px 12px; }
  #loop button { width: max(2.333rem, 40px); }
  .tempo input, .xfade input { min-height: 40px; }
  .strip { gap: 8px; }
  .arrange { --lane-min: 1.6rem; }
  .module-body { gap: 8px; }
  .module select { font-size: max(0.833rem, 12px); }
  .knob { width: max(2.667rem, 40px); }
  .ctl { font-size: max(0.75rem, 9px); }
  .switches { width: 100%; }
  .switches button { flex: 1; width: auto; font-size: max(0.917rem, 12px); }
  .fader { width: 44px; height: max(6rem, 120px); }
  .vfader::-webkit-slider-thumb { width: 44px; height: 14px; }
  .vfader::-moz-range-thumb { width: 44px; height: 14px; }
  .pad { min-height: 52px; }
  .presets button { min-height: 36px; }
  .cheat { padding-block: 8px; }
  .roll { --row-h: max(1rem, 28px); }
  .drum-rows { grid-auto-rows: var(--fit-row, minmax(32px, 1fr)); }
  .grip { width: min(16px, 40%); }
}


/* More contrast (see the tokens at the top): every control is outlined, focus
   is a thicker ring, and what is otherwise shown by a shade is shown by an
   outline or a hatch as well. */
:root[data-contrast="more"] :is(button, select, input, a, .knob, [tabindex]):focus-visible { outline-width: 3px; }
:root[data-contrast="more"] :is(button:not(.key):not(.kb):not(.step), select, input[type="number"], input[type="text"], .menu summary) { border-color: var(--ink); }
:root[data-contrast="more"] :is(button[aria-pressed="true"], .menu[open] summary) { outline: 2px solid var(--on-accent); outline-offset: -4px; }
:root[data-contrast="more"] .step { border: 1px solid var(--ink-muted); }
:root[data-contrast="more"] .step.on { border-color: var(--ink); }
:root[data-contrast="more"] .note:not(.ghost) { outline: 1px solid var(--surface-100); }
:root[data-contrast="more"] .strip.selected { box-shadow: inset 0 0 0 4px var(--accent); }
:root[data-contrast="more"] .ctl.na { opacity: 0.55; }
:root[data-contrast="more"] .knob { --ring: var(--ink-muted); }
/* the roll: rows of white and black keys apart, those out of the scale hatched */
:root[data-contrast="more"] .lane.black { background: var(--raised); }
:root[data-contrast="more"] .lane.out {
  filter: none;
  background-image: repeating-linear-gradient(135deg, var(--border-strong) 0 1px, transparent 1px 7px);
}
:root[data-contrast="more"] input[type="range"]:not(.vfader)::-webkit-slider-runnable-track { background: var(--ink-muted); }
:root[data-contrast="more"] input[type="range"]:not(.vfader)::-moz-range-track { background: var(--ink-muted); }

/* ---------------------------------------------------------------------------
   The full layout: the parts of the screen in dockable panels (Dockview,
   see layout.js). Its chrome takes the colours of the theme.
   --------------------------------------------------------------------------- */
.dock-host, .menubar, .layout-only { display: none; }
/* the menubar on top, the panels under it */
:root.docked body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
:root.docked .menubar { display: flex; }
:root.docked .dock-host { display: block; flex: 1 1 0; min-height: 0; }
:root.docked .layout-only { display: revert; }
/* The controls keep one size in the panels, set in the View menu (see the
   size of the controls in layout.js), instead of following the window. */
:root.docked { font-size: var(--ui-size, 14px); }
/* the Show buttons give way to the switches of the menubar */
:root.docked :is(.console, #view) { display: none; }

/* Dockview's chrome in the app's colours (its variables, set for the theme
   layout.js gives it), in light and in dark alike */
.dockview-theme-ejss {
  --dv-paneview-active-outline-color: var(--accent);
  --dv-tabs-and-actions-container-font-size: 12.5px;
  --dv-tabs-and-actions-container-height: 28px;
  --dv-drag-over-background-color: color-mix(in srgb, var(--accent) 22%, transparent);
  --dv-drag-over-border-color: var(--accent);
  --dv-tabs-container-scrollbar-color: var(--border-strong);
  --dv-icon-hover-background-color: var(--border);
  --dv-floating-box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  --dv-overlay-z-index: 999;
  --dv-group-view-background-color: var(--surface-200);
  --dv-tabs-and-actions-container-background-color: var(--surface-200);
  --dv-activegroup-visiblepanel-tab-background-color: var(--surface-200);
  --dv-activegroup-hiddenpanel-tab-background-color: var(--surface-200);
  --dv-inactivegroup-visiblepanel-tab-background-color: var(--surface-200);
  --dv-inactivegroup-hiddenpanel-tab-background-color: var(--surface-200);
  --dv-tab-divider-color: transparent;
  --dv-activegroup-visiblepanel-tab-color: var(--ink);
  --dv-activegroup-hiddenpanel-tab-color: var(--ink-muted);
  --dv-inactivegroup-visiblepanel-tab-color: var(--ink);
  --dv-inactivegroup-hiddenpanel-tab-color: var(--ink-muted);
  --dv-separator-border: transparent;
  --dv-paneview-header-border-color: color-mix(in srgb, var(--ink) 9%, transparent);
  --dv-sash-color: transparent;
  --dv-active-sash-color: var(--accent);
  --dv-background-color: var(--surface-100);
  --dv-border-radius: 8px;
  height: 100%;
  background: var(--surface-100);
  font-family: var(--font-sans);
}
.dockview-theme-ejss .dv-groupview { border-radius: 8px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--ink) 9%, transparent); }
.dockview-theme-ejss .dv-tab.dv-active-tab { box-shadow: inset 0 -2px 0 var(--accent); }
.dockview-theme-ejss .dv-tab { padding: 0 12px; }

/* A view: what it holds fills it, in the app's type. Each is a container,
   so that what is in it can fit itself to the size of its panel (see the
   @container rules below). */
.ejss-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  font: 1rem/1.3 var(--font-sans);
  container-type: size;
}
.ejss-scenes { container-name: scenes; }
.ejss-timeline { container-name: song; }
.ejss-mixer { container-name: mixer; }
.ejss-output { container-name: output; }
.ejss-sound { container-name: sound; }
.ejss-roll { container-name: roll; }
.ejss-drums { container-name: drums; }
.ejss-code { container-name: code; }
.ejss-view > .launcher { flex: 1 1 auto; }
.ejss-view > .bar { padding: 0.5rem 0.667rem; }
.ejss-view > .panel {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: none;
}
.ejss-view > .mixer { flex: 1 1 auto; padding: 0.5rem; }
.ejss-view > .strudel { flex: 1 1 auto; }
.ejss-output { padding: 0.5rem; }
.ejss-output > .strip.song-panel { flex: 1 1 auto; width: auto; min-width: 0; border: 0; padding: 0; background: none; }
/* the song, while song mode is off */
.ejss-empty { display: none; margin: auto; padding: 0.5rem 1rem; text-align: center; text-transform: none; letter-spacing: 0; font-weight: 400; }
.ejss-empty b { color: var(--ink); }
.ejss-empty .song-on { margin: 0 0.25rem; padding: 1px 0.5rem; font-size: 0.917rem; }
/* the song fills its panel: the blocks of its scenes as tall as there is room */
.ejss-timeline > #timeline-row { flex: 1; }

/* The menubar: the menus, the transport and the switches of the panels, in a
   translucent strip along the top, as on a Mac */
.menubar {
  position: relative;
  z-index: 50;
  flex: none;
  align-items: center;
  gap: 1rem;
  min-height: 2.75rem;
  padding: 0.25rem 0.667rem;
  background: color-mix(in srgb, var(--surface-200) 85%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 9%, transparent);
  /* it fits itself to its width too: see the @container menubar rules */
  container: menubar / inline-size;
  flex-wrap: wrap;
  row-gap: 0.25rem;
}
.mb-left, .mb-menus, .mb-slot { display: flex; align-items: center; }
.mb-left { flex: none; gap: 0.5rem; }
.menubar h1 { font-size: 1.417rem; }
.menubar h1 span { display: none; } /* the name is in its label */
.mb-menus { gap: 2px; }
.mb-menu { position: relative; }
.mb-title {
  padding: 0.25rem 0.667rem;
  background: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.mb-title:hover { background: var(--border); }
.mb-title[aria-expanded="true"] { background: var(--accent); color: var(--on-accent); }
.mb-drop {
  left: 0;
  right: auto;
  top: calc(100% + 0.333rem);
  max-height: calc(100dvh - 4rem);
  overflow: auto;
  border-color: color-mix(in srgb, var(--ink) 9%, transparent);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.4);
}
.mb-drop[hidden] { display: none; }
.menu-section, .mb-slot-menu { display: contents; }
/* the rest scrolls sideways if the window is too narrow for it */
.mb-rest {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.mb-rest > * { flex: none; }
.mb-transport { gap: 0.5rem 0.75rem; margin-inline: auto; }
.menubar button { white-space: nowrap; }
/* the transport keys are their symbols alone, as on a media bar (the
   names are in their tooltips) */
.menubar .round { min-width: 2.5rem; padding: 0.25rem 0.75rem; }
.menubar .key-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mb-status { gap: 0.5rem; }
.mb-show { gap: 2px; padding-left: 0.75rem; border-left: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); }
.mb-icon { display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0; background: none; }
.mb-icon svg { width: 1.167rem; height: 1.167rem; }
.mb-icon[aria-pressed="false"] { color: var(--ink-muted); }
/* Strudel's status: a light and a few words (see bindStatus in layout.js) */
.menubar #status {
  display: block;
  max-width: 12rem;
  padding: 1px 0.5rem;
  overflow: hidden;
  border-radius: var(--radius-sm);
  font-size: 0.833rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: default;
}
.menubar #status::before {
  content: "";
  display: inline-block;
  margin-right: 0.417rem;
  vertical-align: 0.05em;
  width: 0.5rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--go);
}
.menubar #status.busy::before { background: var(--warn); animation: status-busy 1s ease-in-out infinite alternate; }
.menubar #status.error::before { background: var(--rec); }
@keyframes status-busy { to { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .menubar #status.busy::before { animation: none; } }
/* the whole message, under it, after a click */
#status-full:popover-open {
  position: fixed;
  inset: auto;
  margin: 0;
  max-width: min(28rem, calc(100vw - 16px));
  padding: 0.5rem 0.667rem;
  background: var(--raised);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.3);
  font: 0.917rem/1.4 var(--font-sans);
}
#status-full.error { background: var(--on-rec); color: var(--rec); }
.menubar #status { cursor: pointer; }

/* Short of width (a narrow window, or big controls), the switches of the
   panels go first: they are in the View menu too. Shorter still, the right
   half of the bar wraps onto a second row rather than scroll out of sight. */
@container menubar (width < 102rem) {
  #mb-show { display: none; }
}
@container menubar (width < 84rem) {
  .mb-rest { flex-wrap: wrap; min-width: auto; overflow: visible; row-gap: 0.25rem; }
}

/* a line of the View menu, ticked while its panel is in view */
.mb-list { display: grid; gap: 1px; }
.mb-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem 0.25rem 1.75rem;
  position: relative;
  background: none;
  font-weight: 400;
  text-align: left;
}
.mb-check:hover { background: var(--border); }
.mb-check[aria-pressed] { background: none; color: var(--ink); }
.mb-check[aria-pressed]:hover { background: var(--border); filter: none; }
.mb-check[aria-pressed="true"]::before { content: "✓"; position: absolute; left: 0.5rem; color: var(--accent); font-weight: 700; }
.mb-check svg { color: var(--ink-muted); }
.mb-drop #layout-reset { margin-top: -0.5rem; padding: 0.25rem 0.5rem 0.25rem 1.75rem; background: none; font-weight: 400; text-align: left; }
.mb-drop #layout-reset:hover { background: var(--border); }
.mb-tips { display: grid; gap: 0.333rem; max-width: 24rem; margin: 0; padding-left: 1.1rem; color: var(--ink-muted); font-size: 0.917rem; }
kbd {
  padding: 0 0.25rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: 0.833rem var(--font-sans);
}

/* ---- Each panel fitted to its size ----
   The controls keep their size; what changes is how a panel lays them out,
   and, when it is short of room, what it leaves out (all of it still in
   reach elsewhere, or by making the panel bigger). */

/* Mixer: the faders are as long as the panel is tall. Short of height, the
   code boxes of the strips go (the sound panel has them too). */
.ejss-mixer .fader { flex: 1 1 7rem; height: auto; min-height: 3.5rem; }
/* The strips share the width before the mixer scrolls: down to about two
   thirds, with M S D – in two rows (see the container query below). */
/* (the strips sit in the mixer's own row, beside the master: they shrink
   together, and past their least width the mixer scrolls) */
.ejss-mixer .channels { display: contents; }
.ejss-mixer .strip.master { order: 9999; } /* (the drums' strips are ordered as the kit's drums) */
.ejss-mixer .channels .strip { flex: 0 1 6.5rem; min-width: 4.5rem; container: strip / inline-size; }
@container strip (max-width: 6rem) {
  .switches { display: grid; grid-template-columns: repeat(2, 1.333rem); justify-content: center; gap: 0.167rem; }
  .strip-head .tag { display: none; }
}
@container mixer (height < 15rem) {
  .strip .code { display: none; }
}

/* Output: taller than wide, the scope and the spectrum are stacked. Narrow,
   the buttons wrap. */
@container output (aspect-ratio < 1) {
  .scopes .scope { width: 100%; height: calc(50% - 0.208rem); }
  .scopes .scope:first-child { top: 0; }
  .scopes .scope:last-child { top: auto; bottom: 0; }
}
@container output (width < 18rem) {
  .song-tools { flex-wrap: wrap; }
  .song-tools button { flex: 1 0 auto; }
}

/* Sound: short of height, the modules show their knobs without their
   pictures. */
@container sound (height < 14rem) {
  .module .display { display: none; }
}

/* Drums: narrow, the level sliders go (as with Levels off) and the steps
   sit closer. Narrower still, the drum names are shorter. */
@container drums (width < 48rem) {
  .drum-row { grid-template-columns: 6rem auto minmax(0, 1fr); }
  .drum-row > :nth-child(3) { display: none; }
  .drum-rows, .drum-vel { --step-gap: 0.25rem; }
}
@container drums (width < 32rem) {
  .drum-row { grid-template-columns: 4.5rem auto minmax(0, 1fr); }
  .drum-rows, .drum-vel { --step-gap: 2px; }
}

/* Piano roll and drums: narrow, the help hint and the tool captions go. */
@container roll (width < 44rem) {
  .roll-head .hint, .roll-head .caption { display: none; }
}
@container drums (width < 44rem) {
  .roll-head .caption { display: none; }
}
/* (their groups of tools wrap, rather than run out of the panel) */
.ejss-view .roll-head .group { flex-wrap: wrap; }

/* The rows of tools above the piano roll and the drums (see fitTools): the
   main row stays one line (what does not fit goes to More), More opens a
   row under it. One height for every control; the arrows, ×2 and ± are
   bare icons until pointed at. */
.drum-heads { flex-wrap: wrap; }
.drum-heads #drum-more { flex: 1 0 100%; }
.more-tools[hidden] { display: none; }
/* (the tools share their line with Bars and Steps: what does not fit goes to More) */
.drum-heads #drum-tools { flex: 1 1 0; }
.ejss-view .main-tools, .ejss-view .main-tools .group { flex-wrap: nowrap; }
.main-tools { overflow: hidden; gap: 0.333rem 1rem; }
.main-tools > *, .main-tools .group > * { flex-shrink: 0; }
.main-tools .group[hidden] { display: none; }
.more-tools { padding-top: 0.333rem; border-top: 1px solid var(--hairline); }
.more-tools .folded { padding-right: 1rem; border-right: 1px solid var(--hairline); }
.more-tools .folded[hidden] { display: none; }
.roll-head :is(button, select) { height: 2rem; line-height: 1; }
.roll-head .icon-btn { min-width: 2rem; padding: 0 0.333rem; background: transparent; border-color: transparent; font-size: 1rem; }
.roll-head .icon-btn:hover { background: var(--border); }
.more-toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 0.333rem; position: relative; }
.more-toggle::after { content: '▾'; font-size: 0.75rem; transition: transform 0.15s; }
.more-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }
/* (some tools of the row are in More, for want of room: a dot says so) */
.more-toggle.has-folded::before {
  content: ''; position: absolute; top: 3px; right: 3px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
svg.dice { width: 1em; height: 1em; margin-right: 0.333rem; vertical-align: -0.125em; }
.dm-key svg.dice { margin-right: 0; width: 1.25em; height: 1.25em; }
/* The channels of the piano roll: one line that scrolls sideways */
.ejss-view .roll-head .channel-strip, .channel-strip {
  flex: 0 1 auto; min-width: 0; flex-wrap: nowrap; overflow-x: auto;
  scrollbar-width: thin; overscroll-behavior-x: contain;
}
.channel-strip > * { flex-shrink: 0; }
/* (its row keeps the length, Clear and help beside it: the strip scrolls instead) */
.ejss-view .seq .heads > .roll-head:first-child { flex-wrap: nowrap; }
.seq .heads > .roll-head:first-child > :not(.channel-strip) { flex-shrink: 0; }

/* Scenes: narrow, the captions go. */
@container scenes (width < 56rem) {
  #bar-scenes .caption { display: none; }
}

/* The tray of hidden panels: a strip under the panels, while there are any */
.ejss-tray {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 0.667rem;
  background: color-mix(in srgb, var(--surface-200) 85%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--ink) 9%, transparent);
  font: 12px/1.2 var(--font-sans);
}
.ejss-tray .caption { margin-right: 0.5rem; }
:root:not(.docked) .ejss-tray { display: none; }
.ejss-tray[hidden] { display: none; }
.tray-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 500;
}
.tray-item svg { color: var(--accent); }

/* Modulation: a row per modulated knob, and the knob itself lit over the
   range it is moved in */
.knob.modulated { --hue: var(--green); }
.knob.modulated::before {
  content: "~";
  position: absolute;
  top: -0.35rem;
  right: -0.2rem;
  color: var(--green);
  font: 700 0.75rem/1 var(--font-mono);
}
.mod-rows { display: flex; flex-direction: column; gap: 0.5rem; }
.mod-empty { margin: 0; color: var(--ink-soft); font-size: 0.75rem; }
.mod-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: "name name remove" "menus menus menus" "graph from to";
  align-items: center;
  gap: 0.25rem 0.333rem;
  padding-top: 0.417rem;
  border-top: 1px solid var(--hairline);
}
.mod-row:first-child { padding-top: 0; border-top: 0; }
.mod-name { grid-area: name; color: var(--ink); font-size: 0.833rem; font-weight: 600; }
.mod-remove { grid-area: remove; }
.mod-menus { grid-area: menus; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.mod-menus select { flex: 1 1 6rem; min-width: 0; }
.mod-row .display { grid-area: graph; width: 100%; min-width: 4rem; height: 2.667rem; }
.mod-row .ctl:nth-last-child(2) { grid-area: from; }
.mod-row .ctl:last-child { grid-area: to; }
.mod-row.cycle { grid-template-areas: "name name remove" "menus menus menus" "graph graph graph" "values values values"; }
.mod-values { grid-area: values; display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; }
.mod-values .ctl { min-width: 2.25rem; }
.mod-values .knob { width: 2rem; }
.mod-values button { min-width: 1.75rem; }
/* A menu that a modulator sets to a value per cycle */
select.modulated { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.mod-values select { flex: 0 1 auto; min-width: 4rem; }

/* A note with a condition (its mark, as on a drum step) or with pitches that
   take turns (⟳ and how many) */
.note[data-mark]::after, .note[data-rounds]::after {
  content: attr(data-mark) " " attr(data-rounds);
  position: absolute;
  inset: 0 auto 0 2px;
  overflow: hidden;
  color: var(--on-accent);
  font: 600 0.667rem/var(--row-h) var(--font-mono);
  white-space: nowrap;
  pointer-events: none;
}
.note[data-mark] { background-image: repeating-linear-gradient(135deg, transparent 0 3px, color-mix(in srgb, var(--on-accent) 22%, transparent) 3px 5px); }
.note-rounds { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.333rem; padding: 0.25rem 0 0; font-size: 0.833rem; color: var(--ink-muted); }
.note-rounds input { flex: 1; min-width: 6rem; font-family: var(--font-mono); }

/* Pattern functions: a chain, a row per function; a function's function
   is a chain of its own, indented under it */
.chain { display: grid; gap: 0.25rem; justify-items: start; }
.chain.nested { margin-left: 1.25rem; padding-left: 0.5rem; border-left: 2px solid var(--hairline); }
.chain-step { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.333rem; }
.chain-step select { max-width: 15rem; padding: 1px 3px; font-size: 0.833rem; }
.chain-arg { display: flex; align-items: center; gap: 0.25rem; font-size: 0.75rem; color: var(--ink-muted); }
.chain-arg input, .chain-step > input { padding: 1px 3px; font: 0.833rem var(--font-mono); }
.chain-arg .chain-number { width: 3.5rem; }
.chain-arg .chain-text, .chain-step > input { width: 11rem; }
.chain-arg select { max-width: 6rem; }
.chain-step button, .chain-add { padding: 1px 0.5rem; font-size: 0.833rem; }
.chain-code { width: 100%; padding: 1px 3px; font: 0.833rem var(--font-mono); }

/* The harmonics of the 'user' waveform: a bar per harmonic, drawn with the pointer */
.harmonics {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 2px;
  height: 5.5rem;
  padding: 0.25rem;
  background: var(--well);
  border-radius: var(--radius-sm);
  touch-action: none;
  cursor: crosshair;
}
.harmonic { position: relative; display: flex; align-items: flex-end; background: var(--hairline); border-radius: 2px; }
.harmonic span { display: block; width: 100%; background: var(--accent); border-radius: 2px; }
/* the number of a MIDI controller that a modulator follows */
.mod-cc { width: 3.5rem; }

/* The Extras dialog */
#extras-dialog { width: min(48rem, 94vw); }
.extras-field { display: grid; gap: 0.25rem; margin: 0.5rem 0; }
.extras-field textarea { width: 100%; font-family: var(--font-mono); font-size: 0.833rem; }
select.snippets { max-width: 8rem; }
/* Hydra's canvas (made by initHydra): in a corner, or behind the whole app */
body[data-visuals="small"] #hydra-canvas, body[data-visuals="large"] #hydra-canvas {
  position: fixed !important; inset: auto 12px 12px auto !important; z-index: 40 !important;
  width: 320px !important; height: 180px !important; border-radius: 8px; box-shadow: 0 4px 20px rgb(0 0 0 / 0.4); pointer-events: none;
}
body[data-visuals="large"] #hydra-canvas { width: 640px !important; height: 360px !important; }
body[data-visuals="full"] #hydra-canvas { position: fixed !important; inset: 0 !important; width: 100vw !important; height: 100vh !important; z-index: 0 !important; pointer-events: none; opacity: 0.6; }

/* ---------------------------------------------------------------------------
   The drums, one at a time: a drums panel too narrow for the grid shows one
   drum at a time, as on a hardware drum machine. Big controls, for a finger.
   --------------------------------------------------------------------------- */
.drums:is(.compact, .low) > :not(.dm) { display: none !important; }
/* The drums when low: the selected drum's steps in a row (see dmLowHead) */
.dm.low { flex-direction: row; align-items: stretch; gap: 0.5rem; }
.dm-low-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; align-content: center; gap: 0.333rem; flex: none; width: 10rem; }
.dm-low-head .dm-drum-name { min-width: 0; text-align: center; overflow: hidden; }
.dm-low-head .dm-drum-name > * { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-low-head .dm-label { text-align: center; white-space: nowrap; }
.drums.low { flex-direction: column; }
.dm-parts { align-self: flex-start; flex: none; }
/* Short, one part at a time: the steps and the lane share what is left */
.drums.short .dm:not(.low) { flex: 1; }
/* The steps of the one-drum view: always two rows of 8 squares, with the
   lane under them in two rows of 8 half as tall. --sq, the side of a
   square, is what the width allows (a panel's width, in cqw) or, in a short
   panel, where the steps have the room left to themselves, the less of
   that and what the height allows (cqh): smaller panels, smaller squares,
   the same shape. */
.dm:not(.low) .dm-step-area { --sq: clamp(2rem, calc((100cqw - 3.5rem) / 8), 6rem); }
.drums.short .dm:not(.low) .dm-step-area {
  flex: 1 1 0; min-height: 0; container: dm-room / size;
  display: flex; flex-direction: column; justify-content: center;
  --sq: max(1.75rem, min(calc((100cqw - 2.5rem) / 8), calc((100cqh - 3.25rem) / 3), 7rem));
}
.drums .dm:not(.low) .dm-step-area > .dm-steps {
  display: grid; grid-template-columns: repeat(8, var(--sq)); justify-content: center;
  gap: 6px; height: auto; flex: none;
}
.drums .dm:not(.low) .dm-step-area > .dm-steps > * { margin-left: 0; }
.drums .dm:not(.low) .dm-step-area > .dm-steps:not(.dm-lane) { grid-auto-rows: var(--sq); }
.drums .dm:not(.low) .dm-step-area > .dm-lane { grid-auto-rows: calc(var(--sq) / 2); }
.drums .dm:not(.low) .dm-step { height: auto; }
.drums.short .dm:not(.low) .dm-steps-head:not(.dm-tools-only) > .dm-tools,
.dm-tools-only > :not(.dm-tools) { display: none; }
.dm-steps-head.dm-tools-only { flex-direction: column; align-items: flex-start; }
.dm.low { flex: 1; min-height: 0; }
.dm.low .dm-step-area { flex: 1; display: flex; align-items: stretch; }
.dm.low .dm-steps:not(.dm-lane) { flex: 1; align-items: stretch; }
.dm.low :is(.dm-lane, .dm-lane-value) { display: none; }
.dm.low .dm-step { height: auto; min-height: 2.5rem; max-height: 6rem; align-self: center; height: 100%; }
.dm {
  display: flex; flex-direction: column; gap: 0.75rem;
  min-height: 0; overflow: auto;
  touch-action: manipulation; user-select: none;
}
.dm[hidden] { display: none; }
.dm button { font: inherit; }
.dm-group { display: flex; gap: 0.4rem; align-items: center; }
.dm-key { min-width: 3rem; height: 2.5rem; padding: 0 0.667rem; border-radius: var(--radius-control); font-size: 0.917rem; font-weight: 600; }
.dm-key.dm-small { min-width: 0; height: 2.25rem; font-size: 0.833rem; }
.dm-field { display: flex; align-items: center; gap: 0.4rem; font-size: 0.833rem; font-weight: 600; }
.dm-field input { width: 5rem; height: 2.25rem; font: 600 1rem var(--font-mono); text-align: center; }
/* (captions as the rest of the app has them) */
.dm-label { font-size: 0.833rem; font-weight: 500; color: var(--ink-muted); }
.dm-pat { min-width: 2rem; height: 2rem; padding: 0; border-radius: var(--radius-control); font-weight: 600; }
.dm-pat.on { background: var(--accent); color: var(--on-accent); }
/* the knobs of the selected drum */
.dm-knobs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
/* The pads, the steps and the sound: cards, as the modules of the Sound panel */
.dm-pad-area, .dm-step-area, .dm-knobs {
  padding: 0.417rem 0.583rem 0.5rem;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}
.dm-drum-name { display: grid; min-width: 6rem; }
.dm-drum-name b { font-size: 1rem; color: var(--accent); }
.dm-drum-name span { font: 0.75rem var(--font-mono); color: var(--ink-muted); }
.dm .dm-knob .knob { width: 3.25rem; }
/* the pads */
.dm-pads { display: grid; grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr)); gap: 0.333rem; }
.dm-pad {
  height: clamp(3rem, 8vh, 5rem); display: grid; place-content: center; gap: 0.15rem;
  border-radius: var(--radius-control); font-weight: 600; font-size: 0.917rem;
}
.dm-pad small { font-weight: 500; font-size: 0.667rem; color: var(--ink-muted); }
.dm-pad.on { background: var(--accent); color: var(--on-accent); }
.dm-pad.on small { color: inherit; opacity: 0.75; }
.dm-pad:active { filter: brightness(1.3); }
.dm-more { font-weight: 600; color: var(--ink-muted); }
/* the steps: 16, in four groups of four, as on the hardware */
.dm-steps-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.dm-steps-head select { height: 2.25rem; }
.dm-steps { display: flex; gap: clamp(3px, 0.4vw, 6px); }
.dm-step {
  /* lit in the colour of its beat, as the steps of the drum grid */
  --step: var(--accent);
  --step-ink: var(--on-accent);
  flex: 1 1 0; min-width: 0; height: clamp(3rem, 14vh, 7rem); padding: 0;
  border: 0; border-radius: var(--radius-sm); font-size: 0.75rem; font-weight: 600;
  background: var(--border);
}
.dm-step[data-group="1"], .dm-step[data-group="3"] { background: var(--border-strong); }
:root:not([data-look]) :is(.dm-step, .dm-bar)[data-group="0"] { --step: var(--blue); --step-ink: var(--blue-bg); }
:root:not([data-look]) :is(.dm-step, .dm-bar)[data-group="1"] { --step: var(--pink); --step-ink: var(--pink-bg); }
:root:not([data-look]) :is(.dm-step, .dm-bar)[data-group="2"] { --step: var(--yellow); --step-ink: var(--yellow-bg); }
:root:not([data-look]) :is(.dm-step, .dm-bar)[data-group="3"] { --step: var(--green); --step-ink: var(--green-bg); }
.dm-steps > :nth-child(4n + 1):not(:first-child) { margin-left: clamp(3px, 0.6vw, 8px); }
.dm-step.on { background: var(--step); color: var(--step-ink); }
.dm-step.accent { box-shadow: inset 0 0 0 3px var(--ink); }
.dm-step.soft { background: color-mix(in srgb, var(--step) 50%, var(--border)); }
.dm-step.mark { font-size: 0.85rem; }
.dm-step.now { outline: 2px solid var(--ink); outline-offset: -2px; }
.dm-key.on, .dm-key[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
/* the sound of the selected drum */
.dm-sound { display: grid; grid-template-columns: repeat(2, minmax(0, 10rem)); gap: 0.35rem; }
.dm-sound select, .dm-sound .action-menu { height: 2rem; min-width: 0; }
/* the pads' tools: what a pad does, and the roll */
.dm-pad-area { display: grid; gap: 0.5rem; }
.dm-pad-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.dm-seg { display: flex; gap: 2px; }
.dm-seg .dm-key { border-radius: 0; }
.dm-seg .dm-key:first-child { border-radius: var(--radius-control) 0 0 var(--radius-control); }
.dm-seg .dm-key:last-child { border-radius: 0 var(--radius-control) var(--radius-control) 0; }
.dm-field select { height: 2.25rem; }
.dm-pad.muted { opacity: 0.4; }
.dm-pad.hit { filter: brightness(1.4); }
.dm-tools { flex-wrap: wrap; }
.dm-tools select { height: 2.25rem; max-width: 11rem; }
/* the lane under the steps: a bar per hit (velocity), or per step (a knob) */
.dm-step-area { display: grid; gap: 0.35rem; }
.dm-lane { height: clamp(2.5rem, 8vh, 4.5rem); touch-action: none; cursor: ns-resize; }
.dm-bar-cell {
  position: relative; flex: 1 1 0; min-width: 0; border-radius: 6px;
  background: var(--well);
  /* the normal level of a hit: a velocity of 100% */
  background-image: linear-gradient(to top, transparent calc(100% / 1.5 - 1px), color-mix(in srgb, var(--ink) 25%, transparent) 0 calc(100% / 1.5), transparent 0);
}
.dm-lane.locks .dm-bar-cell { background-image: none; }
.dm-bar { --step: var(--accent); position: absolute; inset: auto 3px 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--step); pointer-events: none; }
.dm-bar.free { opacity: 0.3; }
.dm-bar[hidden] { display: none; }
.dm-lane-value { display: flex; align-items: center; gap: 0.5rem; min-height: 1.25rem; font: 0.8rem var(--font-mono); color: var(--ink-muted); }
/* A very narrow panel: the steps in two rows of eight */
.drums { container-type: inline-size; }
@container (max-width: 32rem) {
  .dm-steps { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .dm-steps > :nth-child(4n + 1):not(:first-child) { margin-left: 0; }
  .dm-steps > :nth-child(8n + 5) { margin-left: 6px; }
  .dm-step { height: 3.5rem; }
  .dm-lane { height: auto; grid-auto-rows: 2.5rem; }
}

/* The chain of patterns, in the drums' tools */
input.chain { width: 9rem; font-family: var(--font-mono); text-transform: uppercase; }

/* Explain (?): a tap shows what a control does, in a bubble */
#explain { min-width: 2rem; font-weight: 800; }
#explain[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
body.explaining :is(button, select, input, .knob, .ctl, .step, .pad, .dv-tab):not(#explain) { cursor: help; }
.explain-bubble {
  position: fixed; z-index: 100; max-width: min(24rem, calc(100vw - 16px));
  padding: 0.5rem 0.75rem; border-radius: var(--radius-md);
  background: var(--raised); color: var(--ink); font-size: 0.875rem; line-height: 1.4;
  border: 1px solid var(--accent); box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  pointer-events: none;
}
.explain-bubble[hidden] { display: none; }

/* Credits (Help › Credits) */
#credits { width: min(40rem, 94vw); }
#credits h3 { margin: 1rem 0 0.25rem; font-size: 0.875rem; }
#credits ul { margin: 0; padding-left: 1.25rem; line-height: 1.5; }
#credits a { color: var(--accent); }

/* Update (Live off): lit while changes wait to be heard */
#update.waiting { background: color-mix(in srgb, var(--time) 35%, transparent); border-color: var(--time); color: var(--ink); }

/* A swipe that reaches the end of a panel's scrolling stops there: it does
   not go on to scroll the page or what holds the panel (on a tablet, pull
   the page down to reload it, say). */
.roll, .arrange, .mixer, .dm, .drum-rows, .launcher, .modules, .cm-scroller { overscroll-behavior: contain; }
