/* One screen: the synth fills it. Everything else sits in the sheet behind the gear, styled
   with Frappe UI's Espresso tokens (dark mode): Inter, the gray scale, its control sizes and radii. */
:root {
  color-scheme: dark;
  --surface-base: #0f0f0f; --surface-modal: #1c1c1c; --surface-gray-2: #262626; --surface-gray-3: #2e2e2e;
  --surface-gray-4: #383838;
  --outline-gray-1: #262626; --outline-gray-2: #2e2e2e; --outline-gray-3: #424242;
  --ink-gray-9: #f8f8f8; --ink-gray-8: #ededed; --ink-gray-7: #c7c7c7; --ink-gray-5: #999999; --ink-gray-4: #7c7c7c;
  --ink-red-4: #f87171; --surface-amber-1: #2a1f0e; --outline-amber-2: #6b4a14; --ink-amber-3: #f5b041;
  --scrim: rgba(0, 0, 0, .6); --shadow-2xl: 0 24px 48px -12px rgba(0, 0, 0, .6);
  --accent: #f2a33a; --on-accent: #171717;   /* (accent.js sets the chosen one) */
  --radius: 8px; --radius-xl: 12px; --radius-2xl: 16px;
  --text-xs: 11px; --text-sm: 12px; --text-base: 13px; --text-lg: 14px; --text-xl: 16px; --text-2xl: 18px;
  --safe-w: calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right));
  --safe-h: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--surface-base);
             color: var(--ink-gray-8); font: 400 var(--text-base)/1.5 Inter, InterVariable, system-ui, -apple-system, sans-serif;
             font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
/* no text selection, callouts or tap flashes: a long press is a held button */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[data-icon] { display: inline-flex; flex: none; }

/* ---------------------------------------------------------------- the synth */
.stage { position: fixed; inset: 0; display: grid; place-items: center; padding: env(safe-area-inset-top)
         env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); touch-action: none;
         background: #18191b; }   /* (the panel's own edge color: no bands beside it) */
#panel { display: block; touch-action: none; aspect-ratio: var(--aspect, 1.56);
         width: min(var(--safe-w), calc(var(--safe-h) * var(--aspect, 1.56))); }

/* ---------------------------------------------------------------- Espresso buttons and inputs */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 10px;
          border: 0; border-radius: var(--radius); font: 500 var(--text-base)/1 inherit; font-family: inherit;
          color: var(--ink-gray-8); background: transparent; cursor: pointer; white-space: nowrap;
          transition: background-color .1s; }
.button.subtle { background: var(--surface-gray-2); }
.button.subtle:hover { background: var(--surface-gray-3); }
.button.subtle:active { background: var(--surface-gray-4); }
.button.ghost:hover { background: var(--surface-gray-2); }
.button.solid { background: var(--accent); color: var(--on-accent); }
.button.solid:hover { filter: brightness(1.08); }
.button.large { height: 40px; padding: 0 14px; font-size: var(--text-lg); border-radius: 10px; }
.button.danger { color: var(--ink-red-4); }
.button.icon-only { width: 32px; padding: 0; }
.button[disabled] { opacity: .5; cursor: not-allowed; }
.button[hidden] { display: none; }
.file input { display: none; }

.control { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--ink-gray-5); }
.input { height: 32px; min-width: 0; padding: 0 28px 0 10px; border: 1px solid transparent; border-radius: var(--radius);
         background: var(--surface-gray-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center;
         color: var(--ink-gray-8); font: inherit; appearance: none; -webkit-appearance: none; }
.input:hover { background-color: var(--surface-gray-3); }
.input:focus-visible { outline: none; border-color: var(--outline-gray-3); background-color: var(--surface-gray-3); }
.grow { flex: 1 1 140px; }

/* ---------------------------------------------------------------- Espresso combobox (Frappe UI Autocomplete) */
.combobox-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
                    padding: 0 8px 0 10px; background-image: none; text-align: left; cursor: pointer; }
.combobox-trigger svg { color: var(--ink-gray-5); flex: none; }
.combobox-trigger[aria-busy="true"] { color: var(--ink-gray-5); cursor: progress; }
.combobox-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combobox-panel { position: fixed; z-index: 4; display: flex; flex-direction: column; gap: 4px; padding: 6px;
                  max-height: min(320px, calc(100dvh - 24px)); background: var(--surface-gray-2);
                  border: 1px solid var(--outline-gray-2); border-radius: var(--radius-xl); box-shadow: var(--shadow-2xl); }
.combobox-panel[hidden] { display: none; }
.combobox-search { flex: none; width: 100%; height: 28px; padding: 0 8px; background-image: none;
                   background-color: var(--surface-gray-3); -webkit-user-select: text; user-select: text; }
.combobox-list { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.combobox-option { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px;
                   padding: 0 10px; border-radius: 6px; color: var(--ink-gray-8); cursor: pointer; }
.combobox-option.active { background: var(--surface-gray-4); }
.combobox-option[aria-selected="true"] { font-weight: 500; color: var(--ink-gray-9); }
.combobox-option svg { color: var(--accent); flex: none; }
.combobox-group { padding: 8px 10px 4px; font-size: var(--text-xs); font-weight: 500; color: var(--ink-gray-5); }
.combobox-empty { padding: 6px 10px; font-size: var(--text-sm); color: var(--ink-gray-5); }
.label .value { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink-gray-7); }
.control[hidden] { display: none; }
/* Espresso slider and switch, in the accent */
.slider { width: 100%; height: 28px; margin: 0; accent-color: var(--accent); touch-action: pan-x; }
.switch-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 32px; height: 20px; margin: 0;
          border-radius: 999px; background: var(--surface-gray-4); cursor: pointer; transition: background-color .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
                 background: var(--ink-gray-9); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(12px); background: var(--on-accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
          background: radial-gradient(circle, var(--swatch-accent) 0 4px, var(--swatch) 4.5px);
          box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--surface-modal), 0 0 0 4px var(--swatch); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: var(--text-sm); color: var(--ink-gray-5); overflow-wrap: anywhere; }
.hint:empty { display: none; }
.mono { font: var(--text-sm)/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-gray-5); }

#gear { position: fixed; top: calc(env(safe-area-inset-top) + 8px); right: calc(env(safe-area-inset-right) + 8px);
        width: 40px; height: 40px; display: none; color: var(--ink-gray-5); background: rgba(28, 28, 28, .7); }
[data-playing] #gear { display: inline-flex; }

/* ---------------------------------------------------------------- the sheet: launcher, then settings (an Espresso dialog) */
.dialog { position: fixed; inset: 0; margin: auto; width: min(420px, calc(100vw - 32px)); height: fit-content;
          max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
          padding: 20px 16px 20px; display: flex; flex-direction: column; gap: 16px; background: var(--surface-modal);
          border-radius: var(--radius-xl); box-shadow: var(--shadow-2xl), 0 0 0 100vmax var(--scrim); }
.dialog[hidden] { display: none; }
.dialog > * { flex-shrink: 0; }   /* (it scrolls when tall: no squeezed controls) */
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font-size: var(--text-2xl); font-weight: 600; color: var(--ink-gray-9); overflow-wrap: anywhere; }
#sheet-close { display: none; }
[data-playing] #sheet-close { display: inline-flex; }
[data-playing] #start { display: none; }

summary { display: flex; align-items: center; gap: 6px; list-style: none; cursor: pointer; font-weight: 500; color: var(--ink-gray-7); }
summary::-webkit-details-marker { display: none; }
.chevron { transition: transform .15s; color: var(--ink-gray-5); }
details[open] .chevron { transform: rotate(90deg); }
.group { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--outline-gray-1); }
.group-title { margin: 0; font-size: var(--text-base); font-weight: 600; color: var(--ink-gray-9); }
.text { color: var(--ink-gray-7); overflow-wrap: anywhere; }
#about b { display: block; font-size: var(--text-lg); font-weight: 600; color: var(--ink-gray-9); }
#about .links { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 2px 0 6px; }
#about .what { display: block; }
#midiact { width: 6px; height: 6px; border-radius: 50%; background: var(--outline-gray-3); }
#midiact.on { background: var(--accent); }

/* ---------------------------------------------------------------- the device can't keep up (an Espresso alert) */
.alert { position: fixed; z-index: 2; left: 50%; top: calc(env(safe-area-inset-top) + 8px); transform: translateX(-50%);
         width: min(520px, calc(100vw - 120px)); display: flex; align-items: flex-start; gap: 10px; padding: 12px;
         background: var(--surface-amber-1); border: 1px solid var(--outline-amber-2); border-radius: var(--radius-xl); }
.alert[hidden] { display: none; }
.alert-icon { color: var(--ink-amber-3); margin-top: 1px; }
.alert.info { align-items: center; width: auto; max-width: calc(100vw - 120px); background: var(--surface-modal);
              border-color: var(--outline-gray-2); box-shadow: var(--shadow-2xl); }
.alert.info .alert-icon { color: var(--accent); margin-top: 0; }
.alert-body { flex: 1; display: flex; flex-direction: column; gap: 10px; color: var(--ink-gray-8); }

/* ---------------------------------------------------------------- a phone or tablet held upright */
#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { position: fixed; inset: 0; z-index: 3; display: grid; place-content: center; justify-items: center;
            gap: 16px; padding: 24px; text-align: center; background: var(--surface-base); color: var(--ink-gray-5); }
  #rotate p { font-size: var(--text-xl); font-weight: 500; color: var(--ink-gray-9); }
  .rotate-icon { color: var(--accent); }
}
