/* The admin panel (layouts/admin), in the web's language: tokens, fonts, links, buttons and fields come from brand.css. This file
   is only what a working tool needs on top: the header, denser type and spacing, tables, cards for takes and releases, and the
   player. Light and dark follow the system. */

.admin {
  /* The working text is a little smaller than the web's reading size, and page titles far smaller than its hero. */
  --wrap: 64rem;
  --fs-ui: 1rem;
  --fs-title: clamp(1.75rem, 1.5rem + 1vw, 2.25rem);
  font-size: var(--fs-ui);
  line-height: 1.6;
}

/* Header ------------------------------------------------------------ */

/* The brand at the left edge of the page column, the links and "Sign out" at the right edge, as in the web's header. */
.admin-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-3);
  padding-block: var(--space-1);
  padding-inline: max(var(--gutter), calc((100% - var(--wrap)) / 2));
}

.brand-note {
  font-family: var(--font-text);
  font-size: var(--fs-s);
  font-weight: 400;
  color: var(--muted);
}

.admin-menu {
  margin-left: auto;
}

.admin-menu > details {
  display: none;
}

.admin-menu-panel,
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-1);
}

.admin-menu-panel {
  gap: 0 var(--space-3);
}

.admin-nav a,
.admin-nav span,
.admin-header .link-button {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0 var(--space-1);
  color: var(--text);
  font-size: var(--fs-s);
  text-decoration: none;
  white-space: nowrap;
}

.admin-nav a:hover,
.admin-nav a[aria-current],
.admin-nav-group:has([aria-current]) > .admin-nav-button,
.admin-header .link-button:hover {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

.admin-header form {
  display: flex;
}

/* A group of links (shared/_nav_group): its button, marked while one of its links is the page, opens them under it in a
   popover, as the audio tags do, with their arrow (.audio-tags-button svg) turned up while they are open. A browser
   without anchor positioning opens them in the middle of the window. */
.admin-nav-group {
  anchor-scope: --admin-nav-group;
}

.admin-nav-button {
  gap: 0.375rem;
  anchor-name: --admin-nav-group;
}

.admin-nav-group:has(> :popover-open) .admin-nav-button svg {
  transform: rotate(180deg);
}

.admin-nav-heading {
  display: none;
}

.admin-nav-menu {
  position-anchor: --admin-nav-group;
  position-area: bottom span-right;
  position-try-fallbacks: flip-inline;
  min-width: anchor-size(width);
  margin: 0;
  padding: var(--space-1) 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

/* The last group (Account) at the right edge of the column opens leftwards, its right edge under the button's. */
.admin-nav-group:last-child .admin-nav-menu {
  position-area: bottom span-left;
}

@supports not (position-area: bottom) {
  .admin-nav-menu {
    margin: auto;
  }
}

.admin-nav-menu:popover-open {
  display: grid;
}

.admin-nav-menu :is(a, .link-button) {
  padding: 0 var(--space-2);
}

/* Narrow, the links and "Sign out" go behind the menu button, as on the web: two thin lines that cross while it is open,
   and the panel under the header across the whole width, on the page colour, with tall rows. */
@media (max-width: 64rem) {
  .admin-header {
    position: relative;
    z-index: 5;
    flex-wrap: nowrap;
  }

  .admin-menu > details {
    display: block;
  }

  .admin-menu-panel {
    display: none;
  }

  .admin-menu:has(> details[open]) .admin-menu-panel {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    display: grid;
    padding: 0 var(--gutter) var(--space-2);
    border-bottom: 1px solid var(--rule);
    background: var(--bg);
    animation: admin-menu-in 0.25s ease-out;
  }

  .admin-menu-panel .admin-nav {
    display: grid;
  }

  .admin-menu-panel :is(.admin-nav a, .admin-nav span, .link-button) {
    min-height: 3rem;
    padding: 0;
    font-size: var(--fs-body);
  }

  /* A group stands open under a quiet heading instead of its button, and a rule parts it from the links around it. */
  .admin-menu-panel .admin-nav > * + * {
    border-top: 1px solid var(--rule);
  }

  .admin-header .admin-nav-button {
    display: none;
  }

  .admin-nav-heading {
    display: block;
    margin: var(--space-2) 0 0;
    color: var(--muted);
    font-size: var(--fs-s);
  }

  .admin-nav-menu:not(:popover-open) {
    position: static;
    display: grid;
    width: auto;
    height: auto;
    padding: 0;
    overflow: visible;
    border: 0;
    background: none;
  }

  .admin-menu-button {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    margin-right: -0.75rem;
    color: var(--text);
    list-style: none;
  }

  .admin-menu-button::-webkit-details-marker {
    display: none;
  }

  .admin-menu details[open] > .admin-menu-button {
    margin-bottom: 0;
  }

  .admin-menu-button:focus-visible {
    outline-offset: 0;
  }

  .admin-menu .bars {
    position: relative;
    width: 1.25rem;
    height: 0.75rem;
  }

  .admin-menu .bars::before,
  .admin-menu .bars::after {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 1.5px;
    border-radius: 1px;
    background: currentColor;
    transition:
      transform 0.25s ease-out,
      top 0.25s ease-out;
  }

  .admin-menu .bars::before {
    top: 0;
  }

  .admin-menu .bars::after {
    top: calc(100% - 1.5px);
  }

  .admin-menu details[open] .bars::before,
  .admin-menu details[open] .bars::after {
    top: calc(50% - 0.75px);
  }

  .admin-menu details[open] .bars::before {
    transform: rotate(45deg);
  }

  .admin-menu details[open] .bars::after {
    transform: rotate(-45deg);
  }
}

@keyframes admin-menu-in {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .admin-menu:has(> details[open]) .admin-menu-panel {
    animation: none;
  }

  .admin-menu .bars::before,
  .admin-menu .bars::after {
    transition: none;
  }
}

/* Page ------------------------------------------------------------- */

.admin-main {
  width: min(100% - 2 * var(--gutter), var(--wrap));
  margin: var(--space-4) auto var(--space-5);
}

/* Signing in (the password, the code, two-factor setup and the recovery codes): one narrow column in the middle of the
   window, across and down (the body is a full-height column, brand.css), with the header kept at the top. The text in it
   stays flush left. */
.admin-auth .admin-main {
  flex: none; /* not stretched to the bottom (brand.css), so the auto margins centre it */
  width: min(100% - 2 * var(--gutter), 28rem);
  margin-block: auto;
  padding-block: var(--space-3) var(--space-5);
}

.admin-auth .stack {
  max-width: none;
}

/* The rhythm: one step between blocks, a larger one before a section heading, a small one under a heading or a hint. */
.admin-main > * + * {
  margin-top: var(--space-2);
}

.admin-main > h2 {
  margin-top: var(--space-4);
}

.admin-main > h3 {
  margin-top: var(--space-3);
}

.admin-main > h1 + * {
  margin-top: var(--space-3);
}

.admin-main > :is(h2, h3) + *,
.admin-main > * + .hint {
  margin-top: var(--space-1);
}

.admin-main > :is(p, ul, ol, details, .note-text, .take) {
  max-width: var(--measure);
}

/* The way back up to the list a page belongs to, small above its heading. */
.back-link {
  margin-bottom: var(--space-1);
  font-size: var(--fs-s);
}

h1 {
  font-size: var(--fs-title);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--fs-h3);
  font-weight: 600;
  line-height: 1.3;
}

h3 {
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1.4;
}

h4 {
  font-size: var(--fs-s);
  font-weight: 600;
  line-height: 1.5;
  color: var(--muted);
}

ul,
ol {
  padding-left: 1.25rem;
}

li::marker {
  color: var(--muted);
}

code,
.secret {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

pre {
  overflow-x: auto;
}

pre:not(.note-text) {
  padding: var(--space-2);
  border-radius: var(--radius);
  background: var(--surface);
}

.token {
  font-size: var(--fs-body);
  overflow-wrap: anywhere;
}

/* Forms ------------------------------------------------------------ */

/* Denser than the web's fields and buttons (which are roomy for reading and tapping), for a screen that is worked in all day;
   a touch screen gets the web's button height back. */
input,
textarea,
select {
  max-width: 100%;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
input[type="url"],
input[type="date"],
textarea,
select {
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  line-height: 1.5;
}

/* A field shown, not typed in (a new note's slug): a dashed edge on the page's colour, its text quieter. */
input[readonly] {
  border-style: dashed;
  background: transparent;
  color: var(--muted);
}

/* A select's list is drawn by the system, which may not follow the page's dark scheme: its options get the page's
   colours, or their light text would sit on a white list. */
option {
  background: var(--bg);
  color: var(--text);
}

.button,
:where(button, input[type="submit"]) {
  min-height: 2.5rem;
  padding: 0.4em 1.25em;
  line-height: 1.4;
}

@media (pointer: coarse) {
  .button,
  :where(button, input[type="submit"]) {
    min-height: 2.75rem;
  }
}

.stack {
  display: grid;
  gap: var(--space-2);
  max-width: 32rem;
}

.stack.note-form {
  max-width: 46rem;
}

.stack.bed-form,
.stack.story-form,
.stack.story-part-form {
  max-width: 40rem;
}

/* The tags in use to tick on a note's or a bed's form, wrapped on a phone (never a strip to scroll). */
.tag-choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
}

.tag-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

/* The audio tags (tag_palette_controller.js): a button with a floating list under it (a popover; it flips above when there is
   no room below, and opens in the middle of the page in a browser without anchor positioning). The search box stays on top
   while the kinds scroll under it, each with a quiet name and its buttons wrapped like text. The tag buttons are small with a
   mouse; a touch screen keeps the buttons' own height. */
.audio-tags-button {
  gap: var(--space-1);
  anchor-name: --audio-tags;
}

/* The arrow that says it opens something, turned up while the list is open; the header's groups have it too. */
.audio-tags-button svg,
.admin-nav-button svg {
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.audio-tags-button:has(+ :popover-open) svg {
  transform: rotate(180deg);
}

.audio-tags-popover {
  position-anchor: --audio-tags;
  position-area: bottom span-right;
  position-try-fallbacks: flip-block;
  width: 22rem;
  max-width: calc(100vw - 2 * var(--space-2));
  max-height: 60vh;
  margin: var(--space-1) 0;
  padding: var(--space-2);
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.audio-tags-popover:popover-open {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--space-2);
}

.audio-tags-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow-y: auto;
}

.audio-tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  min-width: 0;
  padding: 0;
  border: 0;
}

.audio-tag-group legend {
  margin-bottom: var(--space-1);
  padding: 0;
  color: var(--muted);
  font-size: var(--fs-s);
  font-weight: 400;
}

@media (pointer: fine) {
  .audio-tag {
    min-height: 0;
    padding: 0.2em 0.75em;
    font-size: var(--fs-s);
    font-weight: 400;
  }
}

/* A row of buttons and links at the end of a form. */
.stack > p:has(> :is(input[type="submit"], button)) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
}

.field-check {
  grid-template-columns: auto 1fr;
  align-items: center;
  justify-content: start;
  column-gap: var(--space-1);
}

.field-check .hint,
.field-check .field-error {
  grid-column: 1 / -1;
}

.field-error {
  color: var(--error);
  font-size: var(--fs-s);
}

.field :is(input[type="email"], input[type="password"], input[type="text"], input[type="url"], textarea) {
  width: 100%;
}

input[type="number"] {
  width: 8rem;
}

/* A date and a 24-hour time (time_field_24h) side by side, as wide as they are, not the width of the page. */
.time-24h {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  justify-self: start;
}

select {
  justify-self: start;
}

/* The words of a note are written in the display face, like on the site. */
.note-form textarea {
  font-family: var(--font-display);
}

input[type="file"] {
  font: inherit;
}

::file-selector-button {
  margin-right: var(--space-2);
  padding: 0.4rem 1rem;
  border: 1px solid var(--text);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* A file field that takes several files dropped on it (a story's parts, images and voice files): a wide box with a
   dashed edge, room to drop them on. */
input[type="file"].drop-zone,
.folder-drop {
  width: 100%;
  padding: var(--space-4) var(--space-3);
  border: 1px dashed var(--muted);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

/* A story's folder (backoffice/stories/_folder): the same box with a button in it, and the file field over the whole
   box, unseen, so the folder can be dropped anywhere on it; its focus rings the box. */
.folder-drop {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

.folder-drop input[type="file"] {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}

.folder-drop:has(input:focus-visible) {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.folder-drop:has(input:hover) .button-secondary {
  border-color: var(--text);
}

fieldset {
  padding: var(--space-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

fieldset.stack {
  max-width: none;
}

legend {
  padding: 0 0.25rem;
}

legend + .hint {
  margin-bottom: var(--space-1);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

.inline-form label {
  font-weight: 600;
}

/* Rails sets size from maxlength, which would make a short label as wide as the page. */
.inline-form :is(input[type="email"], input[type="text"]) {
  width: 22rem;
}

/* The time field is as wide as its five characters (its size), not as wide as a .field or an .inline-form makes text. */
.time-24h input[type="text"] {
  width: auto;
}

form.inline,
form.inline button {
  display: inline;
}

/* Buttons that are links, and the dangerous one -------------------------- */

.link-button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-weight: 400;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

.link-button:hover {
  background: none;
  color: var(--primary);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

.button-danger {
  border-color: var(--error);
  background: var(--error);
}

.button-danger:hover {
  background: transparent;
  color: var(--error);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
}

/* A take that has nothing to offer (still queued, failed) leaves its row of actions empty. */
.actions:not(:has(> *)) {
  display: none;
}

summary {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  cursor: pointer;
}

details[open] > summary {
  margin-bottom: var(--space-2);
}

.recovery {
  margin-top: var(--space-4);
}

.recovery > .hint {
  margin-top: var(--space-1);
}

/* Messages and warnings ----------------------------------------------- */

.flash {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}

/* A message that is a list of reasons. */
ul.flash {
  padding-left: 2.25rem;
}

.flash-alert {
  border-color: var(--error);
}

.flash-warning {
  border-color: var(--warning);
}

.list-warnings,
.release-warnings {
  padding: var(--space-1) var(--space-2) var(--space-1) 2.25rem;
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  background: var(--surface);
}

.badge {
  display: inline-block;
  padding: 0 0.5rem;
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-text);
  font-size: var(--fs-s);
  font-weight: 400;
  line-height: 1.5;
}

h3 .badge {
  margin-left: 0.25rem;
}

.badge-chosen {
  border-color: var(--primary);
  color: var(--primary);
}

.badge-failed {
  border-color: var(--error);
}

/* A badge that leads to where it is put right (No mix: the mix editor), with an arrow and a fill on hover. */
.badge-link {
  text-decoration: none;
}

.badge-link::after {
  content: " →";
}

.badge-link:hover {
  background: var(--surface);
  color: var(--text);
}

/* Lists, tables and facts ---------------------------------------------- */

.events {
  padding-left: 1.25rem;
}

.codes {
  columns: 2;
  max-width: 24rem;
  padding: var(--space-2) var(--space-2) var(--space-2) 2.5rem;
  border-radius: var(--radius);
  background: var(--surface);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-s);
}

th,
td {
  padding: 0.5rem var(--space-2) 0.5rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

th {
  border-bottom-color: var(--muted);
  color: var(--muted);
  font-weight: 600;
}

/* Numbers line up on the right, in figures of one width, so their sizes compare at a glance. */
:is(th, td).number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stats-table td > .hint {
  display: block;
  width: fit-content;
}

/* The Stats page's posts by network and by order: two groups of links on one line, apart as the header's groups are. */
.stats-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-3);
}

/* A story's numbers (backoffice/stories/_numbers): a small chart a part, side by side where they fit, each network a
   line in its colour (checked for colour blindness against both surfaces: blue and orange), the same colour as its
   swatch in the legend and its table row; grid and axis recessive, labels in the text's colours. */
.chart-series-1 {
  --series: light-dark(#2a78d6, #3987e5);
}

.chart-series-2 {
  --series: light-dark(#eb6834, #d95926);
}

/* A numbers section's groups (the headline tiles, the chart with its legend and caption, the table) far apart, the
   things in a group close (Refactoring UI: more space between groups than within them; the founder, 2026-11-02: it was
   all crammed together). Specific enough to win over the story page's and the part page's own section spacing. */
:is(.story-layout, .admin-main) > section.numbers > * + * {
  margin-top: var(--space-4);
}

:is(.story-layout, .admin-main) > section.numbers > h2 + * {
  margin-top: var(--space-3);
}

:is(.chart-group, .parts-chart) > * + * {
  margin-top: var(--space-2);
}

:is(.chart-group, .parts-chart) > .hint {
  max-width: var(--measure);
  margin-top: var(--space-1);
}

/* The table's rows by part: a rule across the whole table above each part, none between its networks' rows. */
.numbers-table .part-rows > tr > * {
  border-bottom: none;
}

.numbers-table .part-rows {
  border-top: 1px solid var(--muted);
}

.numbers-table .part-rows > tr:first-child > * {
  padding-top: var(--space-2);
}

.numbers-table .part-rows > tr:last-child > * {
  padding-bottom: var(--space-2);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  padding: 0;
  list-style: none;
  font-size: var(--fs-s);
}

.chart-swatch {
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  margin-right: 0.4em;
  border-radius: 2px;
  background: var(--series);
  vertical-align: baseline;
}

/* The story's chart of all its parts (parts_chart_controller.js): a part a colour, the categorical order's slots from
   the fourth on (yellow, magenta, green, violet, red), well clear of the networks' blue and orange, so a part never
   looks like a network; stepped for each theme; a part keeps its slot by number (StoryNumbers::PART_COLOURS). */
.parts-chart,
.numbers-table {
  --chart-part-1: light-dark(#eda100, #c98500);
  --chart-part-2: light-dark(#e87ba4, #d55181);
  --chart-part-3: light-dark(#008300, #008300);
  --chart-part-4: light-dark(#6250d6, #9085e9);
  --chart-part-5: light-dark(#e34948, #e66767);
}

.chart-part-1 { --series: var(--chart-part-1); }
.chart-part-2 { --series: var(--chart-part-2); }
.chart-part-3 { --series: var(--chart-part-3); }
.chart-part-4 { --series: var(--chart-part-4); }
.chart-part-5 { --series: var(--chart-part-5); }

/* The network shown: its button filled, the other outlined. */
.parts-chart .button-secondary[aria-pressed="true"] {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

/* The canvas needs a box of a set height to fill (Chart.js, maintainAspectRatio off). */
.parts-chart-box {
  position: relative;
  height: 18rem;
}

.views-chart {
  width: 100%;
  max-width: 36rem;
  height: auto;
  overflow: visible;
}

.chart-grid {
  stroke: var(--rule);
  stroke-width: 1;
}

.chart-axis,
.chart-label {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-axis {
  fill: var(--muted);
}

.chart-label {
  fill: var(--text);
}

.chart-line {
  fill: none;
  stroke: var(--series);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dot {
  fill: var(--series);
  stroke: var(--bg);
  stroke-width: 2;
}

/* A read's hover target, larger than the line; it shows its title. */
.chart-hit {
  fill: transparent;
}

.chart-hit:hover {
  fill: var(--rule);
}

.numbers-table th[scope="row"] {
  color: var(--text);
  font-weight: 400;
}

/* A column as narrow as its checkbox or button, which sits in the middle of the row. */
:is(th, td).cell-tight {
  width: 1px;
  padding-right: var(--space-1);
}

.cell-tight input[type="checkbox"] {
  display: block;
}

/* The beds list is one form: the table, its rows centred on the play buttons and kept to one line (a phone scrolls the
   table sideways), then the buttons for the ticked beds and what they do. */
.beds-list > * + * {
  margin-top: var(--space-2);
}

.beds-list > * + .hint {
  margin-top: var(--space-1);
}

.beds-list :is(th, td) {
  vertical-align: middle;
  white-space: nowrap;
}

/* Replacing a bed is one form too: the bed for all its notes, then the table of notes as wide as the page, each row
   with its own choice, then the button. */
.replace-form > * + * {
  margin-top: var(--space-2);
}

.replace-form td {
  vertical-align: middle;
}

/* Stories ------------------------------------------------------------ */

/* The stories list and a story's page: the title with the one action at the right edge of the content (under the title
   when they do not fit). */
.story-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
}

.story-head form {
  display: flex;
}

/* A card that is a link as a whole, as a tile is: its link's box covers it, and the card's edge darkens under the
   pointer. An action of its own (Process again) sits above that box. */
.card-link {
  color: inherit;
  text-decoration-color: var(--muted);
}

.card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.card-link:hover {
  text-decoration-color: currentColor;
}

.card-link:focus-visible {
  outline: none;
}

.card-link:focus-visible::after {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

:is(.story-card, .story-parts > li):has(.card-link:hover) {
  border-color: var(--muted);
}

.card-action {
  position: relative;
  z-index: 1;
}

/* A part's poster, in the shape of the part (9 by 16), on the empty surface until there is one. */
:is(.story-poster, .story-part-poster) {
  display: block;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: calc(var(--radius) / 2);
  background: var(--surface);
}

:is(.story-poster, .story-part-poster) img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The list: a card per story, side by side as they fit (as wide as the tiles at least) and stacked on a phone. Part 1's
   poster at the left, as wide as the largest step, and the words beside it: the title, the parts, the state, and how many
   parts are out on each network. */
.admin-main > .story-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: var(--space-2);
  max-width: none;
  margin-top: var(--space-3);
  padding: 0;
  list-style: none;
}

.story-card {
  position: relative;
  display: grid;
  grid-template-columns: var(--space-5) minmax(0, 1fr);
  align-items: start;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.story-card h2 {
  font-size: var(--fs-body);
}

.story-card-text > * + * {
  margin-top: var(--space-1);
}

/* How many parts are out on each network, across the card under the poster, in the part cards' two rows. */
.story-card .chips {
  grid-column: 1 / -1;
}

/* A story's page under its heading, one column top to bottom (the founder, 2026-11-01: the side column felt odd): the
   upload, the images, the story's details, and its parts last, a section each between thin rules. The text and forms
   keep the reading width; the parts take the page's. */
.admin-main > .story-layout {
  margin-top: var(--space-4);
}

.story-layout section > :not(.story-parts, .tiles, .parts-chart, .table-wrap) {
  max-width: var(--measure);
}

:is(.story-layout section, .part-media, .social-posts, .story-images, .other-ways) > * + * {
  margin-top: var(--space-2);
}

:is(.story-layout section, .social-posts) > :is(h2, h3) + *,
:is(.story-layout section, .social-posts) > * + .hint {
  margin-top: var(--space-1);
}

.story-layout > section + section {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule);
}

/* The other ways to add, a section each, a step apart. */
.other-ways > section + section {
  margin-top: var(--space-3);
}

/* A story's folder (backoffice/stories/_folder): what it changes, a line a part, and the bar while its files go. */
.folder-plan > * + * {
  margin-top: var(--space-1);
}

.folder-plan progress,
.film-form progress {
  width: 100%;
}

/* The plan of a story's posts (backoffice/stories/_plan): its three fields on a row as they fit, the networks on a
   line, no frame (as on the Post panel), then a row a part with the time it goes and what stays, in columns; on a phone
   each row wraps instead. */
.stack.series-plan {
  max-width: 44rem;
}

.plan-fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
}

.plan-networks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  padding: 0;
  border: none;
  border-radius: 0;
}

.plan-networks legend {
  float: left;
  width: 100%;
  padding: 0;
  font-weight: 600;
}

:is(.plan-networks, .plan-parts) .field-check {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.plan-parts {
  display: grid;
  grid-template-columns: fit-content(18rem) max-content minmax(0, 1fr);
  gap: var(--space-1) var(--space-3);
  padding: 0;
  list-style: none;
}

.plan-parts > li {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: baseline;
}

@media (max-width: 40rem) {
  .plan-parts > li {
    display: flex;
    flex-wrap: wrap;
    column-gap: var(--space-2);
  }
}

/* Its parts as cards, side by side as they fit, as wide as the stories' cards on the list and in their shape (one a row
   on a phone): its poster at the left, its number and title (the link), its state on the site and its length beside
   it, and the networks across the card. */
.story-parts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: var(--space-2);
  padding: 0;
  list-style: none;
}

.story-parts > li {
  position: relative;
  display: grid;
  grid-template-columns: var(--space-5) minmax(0, 1fr);
  align-content: start;
  align-items: start;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.story-parts .chips {
  grid-column: 1 / -1;
}

/* Where a part is on each network, in two rows (the founder, 2026-11-01): the networks' names side by side, each one's
   state in words under it, and a line over each saying it too (the accent once posted, the error colour after a
   failure, dashed while it is on its way or was only simulated). */
.chips {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: space-between;
  gap: 0.25rem;
  padding: 0;
  list-style: none;
}

.chip {
  display: flex;
  flex-direction: column;
  padding-top: 0.25rem;
  border-top: 2px solid var(--rule);
  font-size: var(--fs-s);
  line-height: 1.5;
}

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

.chip-posted {
  border-color: var(--primary);
}

.chip-posted .chip-state {
  color: var(--primary);
}

.chip-failed {
  border-color: var(--error);
}

.chip-failed .chip-state {
  color: var(--error);
}

.chip-posting {
  border-top-style: dashed;
  border-color: var(--warning);
}

.chip-simulated {
  border-top-style: dashed;
  border-color: var(--muted);
}

/* A post waiting for its time: nothing sent yet. */
.chip-scheduled {
  border-top-style: dotted;
  border-top-color: var(--primary);
}

/* Its images, folded: their list and the field to add more, a step apart. */
.story-images > * + * {
  margin-top: var(--space-2);
}

/* A part's web copy: a small player in the shape of the part, which loads nothing but its poster before it is played
   (the posting screen). */
.story-preview {
  display: block;
  width: 8rem;
  aspect-ratio: 9 / 16;
  border-radius: var(--radius);
  background: var(--surface);
}

/* A part's page, one column top to bottom (the founder, 2026-11-01: as a story's page): its small player with its
   files folded beside it, then the work in the order it is done (Post across the page, then its details). */
/* The player with its files beside the details, Post under both across the page; stacked on a narrow screen. */
.admin-main > .part-layout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: var(--space-4);
  margin-top: var(--space-3);
}

@media (max-width: 48rem) {
  .admin-main > .part-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Under them, across the page, the Post panel (in its frame) and the part's numbers, each after a rule. */
.admin-main > :is(#post-panel, .part-numbers) {
  display: block;
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule);
}

/* Its text, chart and table keep one reading width, so the table's numbers sit under the chart, not across the page. */
.part-numbers > :not(h2) {
  max-width: var(--measure);
}

.part-media {
  display: grid;
  justify-items: start;
  gap: var(--space-2);
}

.part-media > * + * {
  margin-top: 0;
}

.part-media p.story-preview {
  display: grid;
  place-items: center;
}

.part-work > * + * {
  margin-top: var(--space-4);
}

.story-part-form > h2 {
  margin-top: var(--space-3);
}

.story-part-form > h2:first-child,
.story-part-form > .flash + h2 {
  margin-top: 0;
}

/* Its Post panel (backoffice/social_posts/_section): a row a network, between thin rules, its box, name and state at
   the left and its connection and other way to post after them (wrapping on a phone), its fields folded under it (as
   wide as the part's form), and the buttons. The rows take the page's width. */
.stack.post-networks {
  max-width: none;
}

/* The rows share their columns (the founder, 2026-11-02: each thing in the same place on every row, at a glance): the
   network's name, its state, what can be done with its post, its numbers, the account, its posting screen, linking a
   post put up by hand; a row's notes go under all but the name. Each row is a subgrid of them, its details laid
   straight into it. A network's fields and the legend span them all. */
.network-rows {
  display: grid;
  grid-template-columns: max-content fit-content(30rem) max-content max-content max-content max-content minmax(0, 1fr);
  column-gap: var(--space-3);
}

/* A state's icon in a place of the same width on every row, so the texts after it start together, icon or not. */
.state-line {
  display: flex;
  align-items: baseline;
}

.state-icon {
  flex: none;
  inline-size: 1.5em;
}

.network-rows > :not(.network-row) {
  grid-column: 1 / -1;
}

.network-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: baseline;
  row-gap: var(--space-1);
  padding-block: var(--space-1);
}

.network-details {
  display: contents;
}


.net-notes {
  grid-column: 2 / -1;
}

.net-notes:not(:has(> :not([hidden]))) {
  display: none;
}

:is(.net-state, .net-action, .net-numbers, .net-account, .net-more, .net-link) > * + * {
  margin-top: 0;
}

.net-notes > * + * {
  margin-top: var(--space-1);
}

/* An icon standing for a line of text (ApplicationHelper#tip_icon): its words in a tooltip above it on hover or
   keyboard focus. */
.tip {
  position: relative;
  display: inline-flex;
  vertical-align: -0.125em;
  color: var(--muted);
  cursor: help;
}

.tip-icon {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linecap: round;
}

/* Laid out only while shown, so a hidden one never widens the page; a tap on a phone focuses the icon and shows it. */
.tip:is(:hover, :focus)::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + var(--space-1));
  left: 50%;
  z-index: 10;
  width: max-content;
  max-width: min(20rem, 80vw);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: var(--fs-s);
  line-height: 1.4;
  white-space: pre-line; /* a line of the tip a line of the tooltip */
  translate: -50% 0;
  pointer-events: none;
}

.tip:focus-visible {
  border-radius: var(--radius);
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* On a narrow screen one column: the name, then each detail under the other. */
@media (max-width: 48rem) {
  .network-rows,
  .network-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .net-notes {
    grid-column: auto;
  }

  /* A detail with nothing in it takes no line (and no gap) here; on a wide screen it keeps its column. */
  .network-details > :not(:has(*)) {
    display: none;
  }
}

.network-row ~ .network-row {
  border-top: 1px solid var(--rule);
}

.post-networks .network-fields {
  max-width: 40rem;
  padding-block: var(--space-1) var(--space-3);
}

/* A fold's link-like button with the folds' sign, pointing down while it is open. */
.fold-toggle::before {
  content: "\25B6";
  margin-right: 0.35em;
  font-size: 0.7em;
}

.fold-toggle[aria-expanded="true"]::before {
  content: "\25BC";
}

/* At the start of a network's row: the sign alone, in a place of the same width on every row. */
.row-toggle {
  inline-size: 1.5em;
  text-align: center;
}

.row-toggle::before {
  margin-right: 0;
}

.network-row > .field-check {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}


/* Its parts are told apart by headings and space, not boxes (the founder, 2026-11-01, by Refactoring UI: fewer
   borders): no frame round Post to or a network's fields, each legend a heading in the flow (floated, so it is laid
   out as any child); the same on a network's own posting screen. */
:is(.post-networks, .post-screen) fieldset {
  padding: 0;
  border: none;
  border-radius: 0;
}

/* The time to post and its hint keep to a reading width, like a network's fields. */
.post-networks > .field {
  max-width: 40rem;
}

:is(.post-networks, .post-screen) legend:not(.visually-hidden) {
  float: left;
  width: 100%;
  padding: 0;
  font-weight: 600;
}



/* Plays a bed's loop (play_button_controller.js): a small square toggle, filled while it plays, with a play or a pause sign. */
.play-button {
  width: 2rem;
  min-height: 2rem;
  padding: 0;
  border-color: var(--muted);
  background: transparent;
  color: var(--text);
}

.play-button:hover {
  border-color: var(--text);
  background: transparent;
  color: var(--text);
}

.play-button[aria-pressed="true"],
.play-button[aria-pressed="true"]:hover {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.play-button svg {
  width: 0.75rem;
  height: 0.75rem;
  fill: currentColor;
}

.play-button[aria-pressed="true"] [data-icon="play"],
.play-button:not([aria-pressed="true"]) [data-icon="pause"] {
  display: none;
}

dl.credits,
dl.counts,
dl.release {
  display: grid;
  gap: 0.25rem;
  max-width: 48rem;
}

dl.credits > div,
dl.counts > div,
dl.release > div {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  gap: 0 var(--space-2);
}

dl.credits dt,
dl.counts dt,
dl.release dt {
  color: var(--muted);
}

dl.credits dd,
dl.counts dd,
dl.release dd {
  min-width: 0;
}

/* A part's voice files on its Edit page, one a line. */
dl.credits .source-files {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* On a phone the long answers get the full width, under their label; the counts stay in two columns. */
@media (max-width: 34rem) {
  dl.credits > div,
  dl.release > div {
    grid-template-columns: minmax(0, 1fr);
  }

  dl.credits dt,
  dl.release dt {
    font-size: var(--fs-s);
  }

  dl.counts > div {
    grid-template-columns: 8rem minmax(0, 1fr);
  }
}

/* Summary tiles (the Overview and Releases): a label, a value in the display face and maybe a short line under it, side
   by side as they fit and stacked on a phone. A tile with a link is a link as a whole. */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--space-2);
}

.tile {
  position: relative;
  padding: var(--space-2);
  border-radius: var(--radius);
  background: var(--surface);
}

.tile dt {
  color: var(--muted);
  font-size: var(--fs-s);
}

.tile dd:first-of-type {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  line-height: 1.3;
}

.tile dd + dd {
  margin-top: 0.25rem;
}

.tile a {
  color: inherit;
  text-decoration-color: var(--muted);
}

.tile a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.tile a:hover {
  text-decoration-color: currentColor;
}

.tile a:focus-visible {
  outline: none;
}

.tile a:focus-visible::after {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* On a phone a tile is one short row: the label at the left, the value at the right, the line under them. */
@media (max-width: 34rem) {
  .tiles {
    gap: var(--space-1);
  }

  .tile {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0 var(--space-2);
    padding: 0.75rem var(--space-2);
  }

  .tile dd:first-of-type {
    font-size: var(--fs-body);
  }

  .tile dd + dd {
    flex-basis: 100%;
    margin-top: 0;
  }
}

/* The working parts of the Releases screen, one card each. */
.admin-main > .card {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.card > * + *,
.release-next > * + * {
  margin-top: var(--space-2);
}

.card > h2 + * {
  margin-top: var(--space-1);
}

@media (max-width: 34rem) {
  .admin-main > .card {
    padding: var(--space-2);
  }
}

/* A row per ready note, between thin rules: its box, its title (which wraps), and what it is at the right edge (under the
   title on a phone). */
.release-notes {
  padding-left: 0;
  border-top: 1px solid var(--rule);
  list-style: none;
}

.release-notes li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0 var(--space-1);
  padding-block: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

.release-notes input[type="checkbox"] {
  align-self: start;
  margin-top: 0.25rem;
}

@media (max-width: 34rem) {
  .release-notes .hint {
    grid-column: 2;
  }
}

/* The published stories, in the same rows without a box to tick: the title, then what the next release does with its
   parts (under the title on a phone). */
.release-stories li {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 34rem) {
  .release-stories li {
    grid-template-columns: minmax(0, 1fr);
  }

  .release-stories .hint {
    grid-column: 1;
  }
}

/* The quiet button: the page colour with a muted edge (Publish anyway, an update of a website that is up to date). */
.button-secondary {
  border-color: var(--muted);
  background: transparent;
  color: var(--text);
}

.button-secondary:hover {
  border-color: var(--text);
}

/* "Publish later…" and "Later…": the forms for a time, folded away under the main buttons. */
.release-later > * + * {
  margin-top: var(--space-1);
}

/* The notes that are not ready, a row per reason that opens to them; and the history, a row per release that opens to
   what it did, with Cancel at the right of one that waits. */
:is(.not-ready, .release-history) {
  padding: 0;
  border-top: 1px solid var(--rule);
  list-style: none;
}

:is(.not-ready > details, .release-history > li) {
  padding-block: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

:is(.not-ready, .release-history) summary {
  color: var(--text);
  text-decoration: none;
}

:is(.not-ready, .release-history) summary:hover {
  text-decoration: underline;
}

:is(.not-ready, .release-history) details[open] > summary {
  margin-bottom: var(--space-1);
}

/* A long group of notes runs in columns. */
.not-ready ul {
  padding-left: 1.125rem;
  list-style: none;
  columns: 3 13rem;
  column-gap: var(--space-3);
}

.not-ready li {
  break-inside: avoid;
}

.admin-main > .release-history {
  max-width: none;
}

.release-history > li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 var(--space-2);
}

.release-history details > * + * {
  margin-top: var(--space-1);
}

/* A narrow window wraps the line between its parts, not inside them. */
.release-history summary :is(span, time) {
  white-space: nowrap;
}

.release-cancel {
  font-size: var(--fs-s);
}

.note-text {
  padding: var(--space-2);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  font-family: var(--font-display);
  white-space: pre-wrap;
}

.issue-preview {
  font-family: var(--font-text);
  white-space: normal;
}

.issue-preview > * + * {
  margin-top: var(--space-2);
}

.issue-preview hr {
  border: 0;
  border-top: 1px solid var(--muted);
}

/* The submissions inbox -------------------------------------------------- */

/* One section per submission: its age, its text set off like a note's, and the actions. */
.admin-main > .submission {
  max-width: var(--measure);
  margin-top: var(--space-4);
}

.submission > * + * {
  margin-top: var(--space-2);
}

.submission > h2 + .hint {
  margin-top: var(--space-1);
}

/* The steps at the top of a note's page: wrapped on a phone, never a strip to scroll. Each opens its part of the page;
   the shown one is filled. The step to do now is bold and boxed in the text colour (the primary colour is for links and
   focus), the done ones are muted with a tick. */
.note-steps {
  margin-top: var(--space-2);
}

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: 0;
  list-style: none;
}

.step > a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem 0 0.25rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: var(--fs-s);
  text-decoration: none;
}

.step > a:hover {
  color: var(--text);
}

.step-mark {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}

.step-now > a {
  border-color: var(--text);
  color: var(--text);
  font-weight: 700;
}

.step-shown > a {
  background: var(--surface);
  color: var(--text);
}

.step-shown .step-mark {
  background: var(--bg);
}

.note-steps > p {
  margin-top: var(--space-1);
}

/* Takes and the player --------------------------------------------------- */

.take {
  padding: var(--space-2);
  border-radius: var(--radius);
  background: var(--surface);
}

.take + .take {
  margin-top: var(--space-2);
}

.take > * + * {
  margin-top: var(--space-2);
}

/* A take on Approve is folded to its line: the heading and the time beside it, in the text colour. */
.take > summary {
  color: var(--text);
  text-decoration: none;
}

.take > summary > h3 {
  display: inline;
  margin-right: var(--space-1);
}

.take > summary:hover > h3 {
  text-decoration: underline;
}

.take[open] > summary {
  margin-bottom: 0;
}

.take .flash {
  background: var(--bg);
}

.processing > * + *,
.player > * + * {
  margin-top: var(--space-1);
}

.processing > h4 {
  margin-top: var(--space-3);
}

.processing > h4 + * {
  margin-top: 0;
}

audio {
  display: block;
  width: 100%;
  max-width: 28rem;
}

.words {
  line-height: 2;
}

/* The words are buttons (keyboard access) that look like the running text. */
.word {
  display: inline;
  min-height: 0;
  margin: 0 -0.1rem;
  padding: 0.1rem;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: inherit;
  font-weight: inherit;
  line-height: inherit;
  transition: none;
}

.word:hover {
  background: var(--bg);
  color: inherit;
}

.word.is-current {
  background: var(--primary);
  color: var(--on-primary);
}

.word:focus-visible {
  outline-offset: 1px;
}

.peaks {
  width: 100%;
  max-width: 14rem;
  height: auto;
  color: var(--text);
}

.peaks path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
}

/* The mix editor --------------------------------------------------------- */

/* The pages wider than the others: the mix editor's timeline, and the stories list, a story's page and a part's page,
   whose cards and columns want the room (the founder, 2026-10-31: they sat in a narrow column on a wide screen). */
.admin:has(.mixer-numbers, .story-cards, .story-layout, .part-layout) {
  --wrap: 80rem;
}

/* Laid out like an audio editor: the transport on top, a time ruler, and a header and a lane for each track. The lanes
   scroll sideways under the headers, which stay put. mixer_controller.js draws the waveforms, the ruler and the music's gain
   line on canvases in the tokens' colours, and places the clips and handles. */
.mixer {
  --mixer-head: 13rem;
  --mixer-ruler: 1.75rem;
  --mixer-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

.mixer-transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.mixer-button {
  gap: 0.45rem;
  min-height: 2rem;
  padding: 0 0.8rem;
  font-size: var(--fs-s);
}

.mixer-button:not(.mixer-play) {
  border-color: var(--muted);
  background: transparent;
  color: var(--text);
}

.mixer-button:not(.mixer-play):hover {
  border-color: var(--text);
}

.mixer-button[aria-pressed="true"],
.mixer-button[aria-pressed="true"]:hover {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.mixer-button:disabled,
.mixer-button:disabled:hover {
  border-color: var(--rule);
  background: transparent;
  color: var(--muted);
}

.mixer-icon {
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  fill: currentColor;
}

.mixer-icon-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Times in a monospaced face with even figures, so they do not jitter while they run. */
.mixer-clock {
  margin-left: 0.5rem;
  font-family: var(--mixer-mono);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mixer-clock-total {
  color: var(--muted);
}

.mixer-zoom {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  color: var(--muted);
  font-size: var(--fs-s);
}

.mixer-zoom input {
  width: 8rem;
}

.mixer-status {
  flex-basis: 100%;
  color: var(--muted);
  font-size: var(--fs-s);
}

.mixer-status:empty {
  display: none;
}

/* The headers in the first column stay put; the timeline in the second scrolls sideways on its own, so its scrollbar
   is only under it. It takes the grid's rows (a subgrid), so a lane is as tall as its header and the other way round.
   Every cell is placed by hand: the overlay (playhead, start and end handles) spans the timeline's rows. */
.mixer-grid {
  display: grid;
  grid-template-columns: var(--mixer-head) minmax(0, 1fr);
  grid-template-rows: var(--mixer-ruler) auto auto;
}

.mixer-scroll {
  display: grid;
  grid-template-rows: subgrid;
  grid-template-columns: max(100%, var(--mixer-lanes, 100%));
  grid-area: 1 / 2 / -1 / 3;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-color: var(--muted) transparent;
  scrollbar-width: thin;
}

.mixer-corner,
.mixer-head {
  grid-column: 1;
  border-right: 1px solid var(--rule);
  background: var(--bg);
}

.mixer-corner {
  grid-row: 1;
  border-bottom: 1px solid var(--rule);
}

.mixer-ruler {
  position: relative;
  grid-area: 1 / 1;
  cursor: pointer;
  touch-action: pan-x;
}

.mixer-grid canvas {
  display: block;
}

.mixer-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.mixer-grid .is-voice {
  grid-row: 2;
}

.mixer-grid .is-music {
  grid-row: 3;
}

.mixer-head-top {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.mixer-name {
  margin-right: auto;
  font-size: var(--fs-s);
  font-weight: 600;
}

/* Mute and Solo: small square toggles, filled when on. */
.mixer-toggle {
  width: 1.75rem;
  min-height: 1.75rem;
  padding: 0;
  border-color: var(--muted);
  background: transparent;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1;
}

.mixer-toggle:hover {
  border-color: var(--text);
  background: transparent;
  color: var(--text);
}

.mixer-toggle[aria-pressed="true"],
.mixer-toggle[aria-pressed="true"]:hover {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

/* The tag filter (when beds have tags) over the bed list, as one item of the header's grid. */
.mixer-beds {
  display: grid;
  gap: 0.375rem;
}

.mixer-bed {
  width: 100%;
  min-height: 2rem;
  padding: 0.15rem 0.5rem;
  font-size: var(--fs-s);
}

.mixer-gain {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mixer-gain input {
  flex: 1;
  width: 100%;
  min-width: 0;
}

.mixer-gain output,
.mixer-readout {
  font-family: var(--mixer-mono);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.mixer-gain output {
  min-width: 4.5rem;
  text-align: right;
}

/* Which slider it is (Gain, Duck), small and quiet before it. */
.mixer-gain-name {
  flex: none;
  width: 2.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.mixer-readout {
  color: var(--muted);
  white-space: nowrap;
}

.mixer-lane {
  position: relative;
  grid-column: 1;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.mixer-lane.is-voice {
  min-height: 5.5rem;
}

.mixer-lane.is-music {
  min-height: 7rem;
}

.mixer-lane > canvas,
.mixer-clip > canvas {
  position: absolute;
  top: 0;
  left: 0;
}

/* A muted (or not soloed) track fades back. */
.mixer-lane.is-silent > * {
  opacity: 0.4;
}

/* The voice clip and the music region: a card on the lane, dragged sideways; the one in hand edged in the accent. */
.mixer-clip,
.mixer-region {
  position: absolute;
  top: 0.5rem;
  bottom: 0.5rem;
  left: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  cursor: grab;
  touch-action: pan-y;
}

.mixer-clip {
  overflow: hidden;
  background: var(--bg);
}

/* The mix's part of the bed: edged in ink, so it stands out of the bed's clip under it. */
.mixer-region {
  border-color: var(--text);
}

.mixer-clip:focus,
.mixer-region:focus,
.mixer-clip.is-dragging,
.mixer-region.is-dragging {
  border-color: var(--primary);
}

.mixer-clip:focus-visible,
.mixer-region:focus-visible {
  outline-offset: 1px;
}

.mixer-clip.is-dragging,
.mixer-region.is-dragging {
  cursor: grabbing;
}

/* Handles: small rounded bars, ink at rest and the accent in hand. */
.mixer-fade,
.mixer-end {
  position: absolute;
  left: -0.5rem;
  width: 1rem;
  cursor: ew-resize;
  touch-action: pan-y;
}

.mixer-fade {
  top: 0;
  z-index: 1;
  height: 1.5rem;
}

.mixer-fade::before,
.mixer-end::after {
  content: "";
  position: absolute;
  left: calc(50% - 4px);
  width: 8px;
  border: 1px solid var(--bg);
  border-radius: 4px;
  background: var(--text);
}

.mixer-fade::before {
  top: 0.25rem;
  height: 1rem;
}

.mixer-fade:hover::before,
.mixer-fade:focus::before,
.mixer-fade.is-dragging::before,
.mixer-end:hover::after,
.mixer-end:focus::after,
.mixer-end.is-dragging::after {
  background: var(--primary);
}

/* The focus ring goes round the bar, not the wider area that catches the pointer. */
.mixer-fade:focus-visible,
.mixer-end:focus-visible {
  outline: none;
}

.mixer-fade:focus-visible::before,
.mixer-end:focus-visible::after {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.mixer-overlay {
  position: relative;
  z-index: 2;
  grid-area: 1 / 1 / -1 / 2;
  pointer-events: none;
}

.mixer-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 2px;
  background: var(--primary);
}

.mixer-playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: -4px;
  width: 10px;
  height: 0.5rem;
  border-radius: 0 0 4px 4px;
  background: var(--primary);
}

/* The end of the mix: a line down the lanes with its grip in the ruler; after it the lanes are dimmed. */
.mixer-end {
  top: 0;
  bottom: 0;
  pointer-events: auto;
}

.mixer-end::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 0.5px);
  width: 1px;
  background: var(--text);
}

.mixer-end::after {
  top: 0.25rem;
  height: 1.25rem;
}

/* The bed after the mix's end, dimmed: it is not heard. */
.mixer-after {
  position: absolute;
  top: var(--mixer-ruler);
  right: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
}

/* A lane whose audio is on its way says so at its start (the view is there while the audio loads), softly pulsing;
   the status line has a spinner meanwhile. */
.mixer-lane[data-loading]::after {
  content: attr(data-loading);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center start;
  padding-left: 1rem;
  color: var(--text);
  font-size: var(--fs-s);
  pointer-events: none;
  animation: mixer-pulse 1s ease-in-out infinite alternate;
}

.mixer-status.is-busy {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mixer-status.is-busy::before {
  content: "";
  flex: none;
  width: 0.875rem;
  height: 0.875rem;
  border: 2px solid var(--rule);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: mixer-spin 0.8s linear infinite;
}

@keyframes mixer-pulse {
  to {
    opacity: 0.4;
  }
}

@keyframes mixer-spin {
  to {
    transform: rotate(1turn);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mixer-lane[data-loading]::after,
  .mixer-status.is-busy::before {
    animation: none;
  }
}

/* The numbers: every setting as a field, in three groups side by side under the timeline (stacked on a phone), the fields
   of a group in as many columns as fit. */
.mixer-numbers > * + * {
  margin-top: var(--space-2);
}

/* Every setting as a number, folded under the timeline (which sets them all) until asked for. */
.mixer-exact[open] > summary {
  margin-bottom: var(--space-2);
}

.mixer-fieldsets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: var(--space-2);
}

@media (min-width: 64rem) {
  .mixer-fieldsets {
    grid-template-columns: 1fr 2fr 1.5fr;
  }
}

.mixer-fieldsets fieldset {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  align-content: start;
  gap: var(--space-2) var(--space-3);
}

/* A field as tall as its row keeps its rows at the top, so the inputs of a row line up. */
.mixer-fieldsets .field {
  align-content: start;
}

.mixer-fieldsets .field-wide {
  grid-column: 1 / -1;
}

.mixer-fieldsets .hint {
  line-height: 1.4;
}

.mixer-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mixer-input input[type="number"] {
  width: 7rem;
  font-variant-numeric: tabular-nums;
}

.mixer-unit {
  color: var(--muted);
  font-size: var(--fs-s);
}

.mixer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
}

/* On a phone the two track panels come first, each across the width, and the timeline under them gets the whole width
   (its rows stay the timeline's: ruler, voice, music, in the grid's last three rows). */
@media (max-width: 40rem) {
  .mixer-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto var(--mixer-ruler) auto auto;
  }

  .mixer-corner {
    display: none;
  }

  .mixer-scroll {
    grid-area: 3 / 1 / 6 / 2;
  }

  /* A panel in two columns: the name and its toggles, then the bed; the bed's part across; the sliders side by side. */
  .mixer-head {
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 0.375rem 0.75rem;
    border-right: 0;
  }

  .mixer-grid .mixer-head.is-voice {
    grid-row: 1;
  }

  .mixer-grid .mixer-head.is-music {
    grid-row: 2;
  }

  .mixer-readout {
    grid-column: 1 / -1;
  }

  /* The name and the number on a line, the slider under them. */
  .mixer-gain {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0;
  }

  .mixer-gain input {
    grid-area: 2 / 1 / 3 / -1;
  }

  .mixer-gain output {
    min-width: 0;
  }

  .mixer-zoom {
    margin-left: 0;
  }

  .mixer-zoom input {
    width: 6rem;
  }
}

/* The code to scan stays on white, light or dark, or an authenticator app cannot read it. */
.qr img {
  width: 12rem;
  height: 12rem;
  padding: 0.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #fff;
}
