@import url("inter.css");

/* The DX7's panel: the brown body, the cyan membrane keys, the pink Store
   key, the grey-blue LCD, the red LEDs and the cream legends. Dark only,
   like the instrument, whatever the system's light or dark setting.

   Each colour has one job:
     cyan    sends to the instruments: Previous, Next, Load, the sliders,
             and the mark on the voice they hold
     LED     a switch that is on (a lit red dot), or the LCD's error light
     key     anything else to press: a grey key with a visible edge
     cream   text, the selected part of a choice, and carriers in the
             algorithm picture
     pink    ratings: Love filled, Like outlined */
:root {
  --bg: #231c18;
  --fg: #f1eee9;
  --muted: #b0a59a;
  --line: #43372f;
  --panel: #2d241f;
  --card: #352b25;
  --well: #1a1512;
  --key: #3a3029;
  --key-edge: #74645a;
  --off-edge: #54463d;
  --off-text: #7d7168;
  --accent: #10c3e2;
  --accent-fg: #231c18;
  --led: #ff3b2e;
  --led-off: #4a2420;
  --love: #ec9a9c;
  --love-fg: #231c18;
  --lcd: #7a809a;
  --lcd-fg: #121016;
  --error: #ff5a4a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

h1 { font-size: 1.5rem; margin: 0.25rem 0 0.5rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 0.75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 0.25rem; }

.lead, .hint { color: var(--muted); }
.hint { font-size: 0.92rem; margin: 0.35rem 0 1rem; }

.status {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 1rem -16px;
  padding: 0.75rem 16px;
  background: var(--panel);
  border-block: 1px solid var(--line);
  font-size: 0.95rem;
}

.error { color: var(--error); font-weight: 600; }

button {
  font: inherit;
  border-radius: 10px;
  cursor: pointer;
}

button.send {
  display: block;
  width: 100%;
  min-height: 3.5rem;
  margin: 0.5rem 0;
  padding: 0.75rem 1rem;
  border: 0;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
  text-align: left;
}

button.secondary, a.link-button {
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--key-edge);
  background: var(--key);
  color: var(--fg);
}

/* A link that looks like a secondary button (the library page's Help). */
a.link-button {
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  text-decoration: none;
}

button:active, a.link-button:active { filter: brightness(0.9); }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  min-height: 3rem;
  border-bottom: 1px solid var(--line);
}

.row label { flex: 1 1 auto; }
.target label:first-of-type { font-weight: 600; flex: 1 1 5rem; }
.target .address-label { flex: 0 1 auto; color: var(--muted); font-size: 0.92rem; }

input[type="checkbox"] { width: 1.6rem; height: 1.6rem; margin: 0; accent-color: var(--fg); }

input[type="number"], select {
  font: inherit;
  min-height: 2.75rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--key-edge);
  border-radius: 8px;
  background: var(--well);
  color: var(--fg);
}

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

/* A slider takes the row's width on its own line, its value beside it. */
input[type="range"] { flex: 1 1 100%; order: 1; min-height: 2.75rem; margin: 0; accent-color: var(--accent); }
.trial output, .control output { font-variant-numeric: tabular-nums; font-weight: 600; }
select { flex: 1 1 12rem; max-width: 100%; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.4rem 0.4rem 0.4rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

.setup dt { font-weight: 600; margin-top: 0.75rem; }
.setup dd { margin: 0.1rem 0 0; }

details { border: 1px solid var(--line); border-radius: 10px; padding: 0.5rem 0.9rem; background: var(--panel); }
summary { cursor: pointer; min-height: 2.5rem; display: flex; align-items: center; font-weight: 600; }
ol { padding-left: 1.4rem; }
li { margin: 0.4rem 0; }
code { font-size: 0.9em; overflow-wrap: anywhere; }

/* The library page. */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

label.file-button {
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  cursor: pointer;
}

label.send.file-button { width: 100%; min-height: 3.5rem; padding: 0.75rem 1rem; background: var(--accent); color: var(--accent-fg); font-weight: 600; }
label.secondary.file-button { min-height: 2.75rem; padding: 0.5rem 1rem; border: 1px solid var(--key-edge); background: var(--key); color: var(--fg); }

/* Room below the list for the dock (its height set by main.js), so the last
   rows can scroll clear of it. */
.library-page main { padding-bottom: calc(var(--dock-height, 9rem) + 1rem); }
.library-page .status { margin-bottom: 0.5rem; }

.view-head { display: flex; align-items: flex-end; gap: 0.75rem; margin: 1rem 0 0.5rem; }
.view-names { min-width: 0; }
.view-head h2 { margin: 0; overflow-wrap: anywhere; }
.view-context { margin: 0; color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
button.up { flex: none; }

.empty p { margin: 0.5rem 0 1rem; }

/* Setup's list of imported .syx files, each with its Remove button. */
.imports { list-style: none; margin: 0; padding: 0; }
.imports li { margin: 0; }
.imports span { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

.items { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }

button.item {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  min-height: 3.75rem;
  padding: 0.55rem 0.5rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  text-align: left;
}

button.item.slot { grid-template-columns: 2.25rem 1fr; column-gap: 0.5rem; }
.slot-number { grid-row: span 2; align-self: center; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.item-name { font-weight: 600; overflow-wrap: anywhere; }
.item-detail { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.slot.unsendable .item-name { color: var(--muted); font-weight: 400; }
.slot.current { background: var(--panel); box-shadow: inset 4px 0 0 var(--accent); }

.tier { display: inline-block; padding: 0 0.4rem; border-radius: 0.6rem; font-size: 0.75rem; font-weight: 600; vertical-align: 0.1em; }

/* The dock: the Edit drawer, when open, above the step bar, both fixed to
   the foot of the screen so the list and the status line stay in view. */
.dock {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 2;
}

/* The step bar: one row. The voice's name, with its bank and slot below,
   then Edit, then Previous and Next as a pair of square keys under the
   right thumb, like the DX7's -1 and +1 keys. */
.bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem max(16px, calc((100% - 40rem) / 2)) calc(0.5rem + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.now-row, .steps { display: contents; }

.drawer > * { max-width: 40rem; margin-inline: auto; }

/* The drawer takes at most about three fifths of the screen's height, so
   the list and the status line stay in view above it. Its head (the name
   line, Reset and Close) stays put while its body scrolls. */
.drawer {
  display: flex;
  flex-direction: column;
  max-height: 60vh;
  max-height: 60dvh;
  padding: 0.75rem 16px 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 16px rgb(0 0 0 / 0.15);
}

.drawer > * { width: 100%; }
.drawer-head { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--line); }
.drawer-names { min-width: 0; }
.drawer-head h2 { margin: 0; overflow-wrap: anywhere; }
.drawer-buttons { flex: none; display: flex; gap: 0.5rem; }
.drawer-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 0.25rem; }
.drawer-note { margin: 0.5rem 0 0; font-size: 0.92rem; }
.drawer .hint { margin-top: 0.5rem; }

/* The voice's own controls, algorithm and feedback, above the operators. */
.voice-controls { padding-bottom: 0.25rem; border-bottom: 1px solid var(--line); }
/* Algorithm and feedback: the name and value on top, then the slider with
   its - and + keys on one line below it. */
.control.nudged { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; column-gap: 0.5rem; }
.control.nudged label { grid-column: 1 / 3; grid-row: 1; }
.control.nudged output { grid-column: 3; grid-row: 1; justify-self: end; }
.control.nudged input[type="range"] { grid-column: 1; grid-row: 2; }
.nudge { grid-row: 2; min-width: 2.75rem; min-height: 2.5rem; padding: 0; font-size: 1.25rem; line-height: 1; }

/* The algorithm's picture (algorithm-diagram.js): one square for every
   algorithm, so it keeps its size as the algorithm changes. Carriers are
   filled cream on the output line; modulators are outlined; feedback dashed. */
.algorithm-picture { display: flex; justify-content: center; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.algorithm-picture svg { width: min(11rem, 100%); height: auto; display: block; }
svg.algorithm text { font: 600 11px "Inter", system-ui, sans-serif; text-anchor: middle; dominant-baseline: central; }
svg.algorithm .op rect { stroke-width: 1.6; }
svg.algorithm .op.carrier rect { fill: var(--fg); stroke: var(--fg); }
svg.algorithm .op.carrier text { fill: var(--bg); }
svg.algorithm .op.modulator rect { fill: var(--bg); stroke: var(--fg); }
svg.algorithm .op.modulator text { fill: var(--fg); }
svg.algorithm .wire { fill: none; stroke: var(--fg); stroke-width: 1.4; }
svg.algorithm .bus { fill: none; stroke: var(--fg); stroke-width: 1.6; }
svg.algorithm .feedback { fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-dasharray: 3 2; }

/* An operator's card: its number marked as in the picture and its role,
   then its frequency slider with the value beside the name and the settings
   below, then its output level. A carrier's mark is filled, as in the picture. */
.operators { display: grid; gap: 0.75rem; padding-top: 0.75rem; }
.operator { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem 0.75rem 0; min-width: 0; }
.operator h3 { margin: 0.25rem 0 0; display: flex; align-items: center; gap: 0.5rem; }
.operator-mark { display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.25rem; border-radius: 2px; font-size: 0.8rem; font-weight: 700; }
.operator.carrier .operator-mark { background: var(--fg); color: var(--bg); }
.operator.modulator .operator-mark { box-shadow: inset 0 0 0 1.6px var(--fg); }
.operator-role { font-weight: 400; color: var(--muted); }
.operator .row { padding-bottom: 0.25rem; }
.operator .row:last-child { border-bottom: 0; }
.frequency-setting { order: 2; flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.25rem; margin: 0; padding: 0; border: 0; }
.frequency-setting input[type="radio"] { width: 1.4rem; height: 1.4rem; margin: 0; accent-color: var(--fg); }
.frequency-setting label { flex: none; min-height: 2.75rem; display: inline-flex; align-items: center; padding-right: 0.75rem; }

button.edit { flex: none; }

button.now {
  display: block;
  min-width: 0;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.15rem 0.25rem;
  border: 0;
  background: transparent;
  color: var(--fg);
  text-align: left;
}
.now-name, .now-where { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-name { font-weight: 600; }
.now-where { color: var(--muted); font-size: 0.8rem; }

button.now:disabled { cursor: default; }

button.step {
  width: 3.25rem;
  height: 3rem;
  padding: 0;
  border: 0;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1;
}

button.step:disabled, button.send:disabled, button.secondary:disabled {
  background: transparent;
  border: 1px dashed var(--off-edge);
  color: var(--off-text);
  cursor: default;
}

/* The library page's head, filter bar and setup view. */

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.page-head h1 { margin: 0.25rem 0; }
/* The app's name, the XD7 wordmark, then what it is in a lighter, smaller
   line: below the wordmark on a phone, beside it on a wide screen. */
.page-head h1 { line-height: 1.15; }
.wordmark { display: block; height: 1.7rem; width: auto; margin-bottom: 0.2rem; color: var(--fg); }
.title-tagline { display: block; margin-top: 0.15rem; font-size: 0.5em; line-height: 1.35; font-weight: 500; color: var(--muted); }
/* The narrowest phones, under 360 pixels: smaller still, so each line fits. */
@media (max-width: 22.45rem) { .title-tagline { font-size: 0.44em; } }
.page-head button { flex: none; }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0 0.25rem; }
.filters input[type="search"] {
  flex: 1 1 14rem;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.25rem 0.75rem;
  font: inherit;
  border: 1px solid var(--key-edge);
  border-radius: 10px;
  background: var(--well);
  color: var(--fg);
}
.filter-buttons { display: flex; gap: 0.5rem; flex: 1 1 auto; }
.filter-buttons button { flex: 1 1 0; white-space: nowrap; }
/* The Show switch: All, Favourites and History as one control, the one on
   filled cream. Shuffle, an action, stands apart as a grey key. */
.show-switch { display: flex; flex: 3 1 auto; min-width: 0; border: 1px solid var(--key-edge); border-radius: 4px; overflow: hidden; }
.show-switch .segment { flex: 1 1 auto; min-height: 2.75rem; padding: 0.5rem 0.6rem; border: 0; border-right: 1px solid var(--key-edge); border-radius: 0; background: var(--key); color: var(--fg); }
.show-switch .segment:last-child { border-right: 0; }
.show-switch .segment[aria-pressed="true"] { background: var(--fg); color: var(--bg); font-weight: 600; }
.show-switch .segment:disabled { color: var(--off-text); cursor: default; }
button.toggle { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
button.toggle::before { content: ""; flex: none; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--led-off); }
button.toggle[aria-pressed="true"] { border-color: var(--fg); font-weight: 600; }
button.toggle[aria-pressed="true"]::before { background: var(--led); box-shadow: 0 0 6px 1px rgb(255 59 46 / 0.7); }

button.more { width: 100%; margin-top: 0.75rem; }
#setup h2:first-child { margin-top: 1rem; }

.head-buttons { display: flex; gap: 0.5rem; }

/* A wide screen (a tablet, a phone on its side, a desktop window), chosen by
   the width alone: every page takes the full width. On the library page the
   step bar is one line along the foot, and the Edit drawer, when open, is a
   pane on the right from the status line down to the bar, the list keeping
   the left; closed, the list has the full width. The status line and the
   step bar span the width either way. The pane is still
   in the dock but out of its flow, so the dock's height (the room the list
   leaves, and where revealing a row stops) is the bar's alone. The same
   elements as on the phone, placed by CSS alone, so turning the screen or
   resizing the window across the breakpoint changes nothing else. */
@media (min-width: 56rem) {
  :root { --pane-width: min(66vw, 100vw - 24rem, 64rem); }

  main { max-width: none; }
  .page-head h1 { display: flex; align-items: center; gap: 0.6rem; }
  .wordmark { margin-bottom: 0; }
  .title-tagline { display: inline; margin-top: 0; font-size: 0.62em; }
  /* A setting's row (a target and its address, the pause, the trial slider)
     keeps a usable length, so its name stays near its box. */
  main .row { max-width: 48rem; }
  .library-page:has(#drawer:not([hidden])) main { margin-right: var(--pane-width); }
  /* The status line still spans the whole width, over the pane's column as
     on the phone, and the pane starts below it: at its foot (--status-foot,
     set by drawer.js), which moves up as the page scrolls until the line
     sticks at the top. */
  .library-page:has(#drawer:not([hidden])) .status { margin-right: calc(-16px - var(--pane-width)); }

  .drawer > * { max-width: none; margin-inline: 0; }
  .bar { padding-inline: 16px; }

  .drawer {
    position: fixed;
    top: var(--status-foot, 0px);
    right: 0;
    bottom: var(--dock-height, 5rem);
    width: var(--pane-width);
    max-height: none;
    border-top: 0;
    border-left: 1px solid var(--line);
    box-shadow: none;
  }

  /* The six operator blocks are a grid whose columns follow the pane's
     width: one, two or three, so the rows are always full. The pane leaves
     the list at least the phone's width, and a frequency setting's three
     choices are a little smaller, so they keep to one line in a column. */
  .drawer-body { container-type: inline-size; }
  /* The algorithm's picture sits beside the voice's own controls, stacked
     in a column, with the operator cards below both. */
  #drawer-controls { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 1.25rem; align-items: center; }
  .algorithm-picture { border-bottom: 0; }
  .algorithm-picture svg { width: 12rem; }
  .operators { grid-column: 1 / -1; }
  .operators { column-gap: 0.75rem; }
  .frequency-setting { gap: 0 0.15rem; }
  .frequency-setting input[type="radio"] { width: 1.25rem; height: 1.25rem; }
  .frequency-setting label { padding-right: 0.4rem; font-size: 0.85rem; }
  @container (min-width: 30rem) { .operators { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  @container (min-width: 50rem) { .operators { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
}

/* The DX7's panel in the details. Keys are near-square, like its membrane
   switches. The status line is its LCD: each message one line in the LCD's
   dark ink, cut short with an ellipsis until a tap opens it in full; an
   error lights a red LED before its line rather than turning the text red.
   A slot's number is a plain label. Ratings are pink, like the Store key. */
button, a.link-button, label.file-button, details, .filters input[type="search"], input[type="number"], select { border-radius: 4px; }
.status { background: var(--lcd); color: var(--lcd-fg); border-block: 0; padding-block: 0.45rem; cursor: pointer;
  font-size: 0.9rem; line-height: 1.5; }
.status br { display: none; }
.status { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.status > span { grid-column: 1; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Retry, when MIDI was refused: a key in the LCD's own ink at the line's right. */
.lcd-key { grid-column: 2; grid-row: 1 / span 2; margin-left: 0.75rem; min-height: 2.5rem; padding: 0 0.85rem;
  border: 0; border-radius: 3px; background: var(--lcd-fg); color: var(--lcd); font-weight: 600; font-size: 0.85rem; }
.status.open > span { white-space: normal; }
.status:focus-visible { outline: 2px solid var(--fg); outline-offset: -3px; }
.status .error { color: var(--lcd-fg); font-weight: 600; }
.status .error::before { content: ""; display: inline-block; width: 0.5rem; height: 0.5rem; margin-right: 0.5rem; border-radius: 50%;
  background: var(--led); box-shadow: 0 0 6px 1px rgb(255 59 46 / 0.75); vertical-align: 0.05em; }
.slot-number { align-self: center; font-weight: 600; font-size: 0.9rem; }
.slot.unsendable .slot-number { color: var(--off-text); }
.tier-love { background: var(--love); color: var(--love-fg); }
.tier-like { border: 1px solid var(--love); color: var(--love); }
a { color: var(--fg); text-underline-offset: 0.15em; }
