/* FM-1 Relay: neon on black, like the iPad and R36S versions. */
:root {
  --cyan: #00ebff; --magenta: #ff33b8; --lime: #94ff29; --orange: #ff850f;
  --yellow: #ffe61f; --red: #ff2942; --violet: #9e5cff;
  --line: #212129; --panel: #09090d; --text: #e9e9ee;
  --font: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: #000; color: var(--text); font: 700 16px/1.25 var(--font); }
body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.relay {
  display: flex; flex-direction: column; gap: 16px;
  min-height: 100dvh; max-width: 1400px; margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

/* top bar */
.top { display: flex; align-items: center; gap: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--line); }
.dots { display: flex; gap: 5px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); }
.dots i:nth-child(2) { background: var(--magenta); } .dots i:nth-child(3) { background: var(--lime); } .dots i:nth-child(4) { background: var(--orange); }
.top h1 { margin: 0; font-size: 22px; letter-spacing: .02em; color: var(--cyan); text-shadow: 0 0 8px rgb(0 235 255 / .7); white-space: nowrap; }
.status { flex: 1; text-align: center; font-size: 20px; color: var(--c, var(--cyan)); text-shadow: 0 0 8px color-mix(in srgb, var(--c, var(--cyan)) 70%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.linked { font-size: 20px; color: var(--lime); text-shadow: 0 0 8px rgb(148 255 41 / .7); white-space: nowrap; }
.icon-btn { display: grid; place-items: center; width: 48px; height: 44px; border: 0; border-radius: 10px; background: none; color: var(--violet); }
.icon-btn:hover { background: rgb(158 92 255 / .12); }

/* connect banner */
.connect { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; border: 2px dashed var(--line); border-radius: 14px; }
.connect p { flex: 1 1 320px; margin: 0; font-weight: 400; color: rgb(255 255 255 / .75); }

/* buttons */
.neon {
  --c: var(--yellow);
  min-width: 64px; min-height: 48px; padding: 0 14px; border-radius: 12px; font-size: 18px;
  color: var(--c); background: color-mix(in srgb, var(--c) 8%, transparent); border: 2px solid var(--c);
  box-shadow: 0 0 6px color-mix(in srgb, var(--c) 60%, transparent);
  transition: background .1s, transform .05s;
}
.neon:hover { background: color-mix(in srgb, var(--c) 18%, transparent); }
.neon:active { transform: scale(.97); }
.neon.filled { color: #000; background: var(--c); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 75%, transparent); }
.neon.lime { --c: var(--lime); } .neon.orange { --c: var(--orange); } .neon.red { --c: var(--red); } .neon.violet { --c: var(--violet); }
.neon.wide { min-width: 88px; } .neon.play { min-width: 170px; }
.small {
  --c: var(--cyan);
  min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: 16px;
  color: var(--c); background: color-mix(in srgb, var(--c) 8%, transparent); border: 2px solid var(--c);
}
.small:hover:not(:disabled) { background: color-mix(in srgb, var(--c) 18%, transparent); }
.small:disabled { opacity: .35; cursor: default; }

/* tempo and reel */
.deck { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.tempo { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.label-row { display: flex; gap: 18px; align-items: baseline; color: var(--yellow); }
.label-row b { font-size: 20px; } .label-row span { font-size: 14px; font-weight: 400; opacity: .45; }
.bpm-row { display: flex; align-items: flex-end; gap: 16px; }
.seg { cursor: ns-resize; touch-action: none; user-select: none; filter: drop-shadow(0 0 10px rgb(255 230 31 / .75)); }
.seg svg { display: block; width: clamp(200px, 30vw, 340px); height: auto; }
.bpm-unit { font-size: 26px; color: var(--yellow); text-shadow: 0 0 6px rgb(255 230 31 / .8); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.barbeat { display: flex; flex-direction: column; gap: 2px; margin-left: 8px; color: var(--yellow); }
.barbeat small { font-size: 16px; opacity: .8; } .barbeat b { font-size: 30px; text-shadow: 0 0 6px rgb(255 230 31 / .8); font-variant-numeric: tabular-nums; }
.reel { width: 330px; height: 330px; flex: none; filter: drop-shadow(0 0 8px rgb(255 230 31 / .6)); }

/* slots */
.slots { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.slot {
  --c: var(--cyan);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 250px; padding: 14px; border-radius: 16px; background: var(--panel); border: 2px solid var(--line); cursor: pointer;
  transition: box-shadow .15s, background .15s;
}
.slot.empty { border: 2px dashed color-mix(in srgb, var(--c) 45%, transparent); }
.slot.sel { border: 3px solid var(--c); background: color-mix(in srgb, var(--c) 8%, transparent); box-shadow: 0 0 16px color-mix(in srgb, var(--c) 55%, transparent); }
.slot-head { display: flex; width: 100%; align-items: center; justify-content: space-between; }
.num { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; font-size: 26px; color: var(--c); }
.slot.sel .num { color: #000; background: var(--c); }
.led { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--a, var(--c)); }
.led.lit { background: var(--a, var(--c)); box-shadow: 0 0 8px var(--a, var(--c)); }
.knob { position: relative; width: 96px; height: 96px; border-radius: 50%; border: 5px solid color-mix(in srgb, var(--c) 50%, transparent); background: color-mix(in srgb, var(--c) 15%, transparent); }
.knob i { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -29px 0 0 -7px; border-radius: 50%; background: color-mix(in srgb, var(--c) 50%, transparent); }
.slot.lit .knob { border-color: var(--c); background: color-mix(in srgb, var(--c) 35%, transparent); box-shadow: 0 0 12px color-mix(in srgb, var(--c) 60%, transparent); }
.slot.lit .knob i { background: var(--c); }
.slot.wait .knob::before { content: ""; position: absolute; inset: -16px; border-radius: 50%; border: 3px dashed var(--yellow); animation: spin 4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.slot.pinged .knob { animation: ping .35s ease-out; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 var(--magenta); } 100% { box-shadow: 0 0 0 22px transparent; } }
.fw, .state { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; color: var(--c); }
.fw { font-size: 22px; } .state { font-size: 20px; margin-top: -6px; }
.slot.dim .fw, .slot.dim .state { opacity: .55; }
.slot.wait .state { color: var(--yellow); opacity: 1; }
.beats { display: flex; gap: 6px; }
.beats i { width: 18px; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--c) 20%, transparent); }
.beats i.on { background: var(--c); }
.slot-btns { display: flex; gap: 8px; width: 100%; }
.slot-btns .small { flex: 1; }
.slot-btns .onoff { --c: var(--sc); } .slot-btns .onoff.off { --c: rgb(255 255 255 / .4); color: rgb(255 255 255 / .5); }
.slot-btns .ping { --c: var(--magenta); }

/* setup line */
.hint { display: flex; align-items: center; gap: 12px; min-height: 30px; font-size: 16px; overflow: hidden; white-space: nowrap; }
.hint .tag { padding: 4px 8px; border-radius: 6px; color: #000; background: var(--c); }
.hint .name { color: var(--c); } .hint .ver { color: var(--c); opacity: .6; font-size: 14px; font-weight: 400; }
.hint .setup { color: rgb(255 255 255 / .85); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.hint .extra { color: var(--magenta); opacity: .85; font-size: 14px; font-weight: 400; }
.hint .muted { color: rgb(255 255 255 / .6); font-weight: 400; }

/* menu */
.menu { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 2px solid var(--violet); border-radius: 18px; background: #0b0b10; color: var(--text); box-shadow: 0 0 30px rgb(158 92 255 / .35); }
.menu::backdrop { background: rgb(0 0 0 / .7); backdrop-filter: blur(2px); }
.menu form { padding: 18px 22px 22px; }
.menu header { display: flex; justify-content: space-between; align-items: center; }
.menu h2 { margin: 0; color: var(--violet); font-size: 20px; }
.menu .done { --c: var(--violet); }
.menu h3 { margin: 22px 0 6px; font-size: 14px; color: var(--violet); letter-spacing: .08em; }
.menu .row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 48px; border-bottom: 1px solid var(--line); font-weight: 400; }
.menu select { min-height: 38px; padding: 0 10px; border-radius: 8px; background: #000; border: 2px solid var(--line); }
.menu input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--lime); }
.menu .note { margin: 8px 0 0; font-size: 13px; font-weight: 400; color: rgb(255 255 255 / .55); }
.menu .keys b { color: var(--text); }
.menu a { color: var(--cyan); }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper .small { min-width: 44px; --c: var(--violet); }
.ports .row span small { display: block; color: rgb(255 255 255 / .45); font-size: 12px; }

/* smaller screens */
@media (max-width: 1100px) {
  .reel { width: 260px; height: 260px; }
}
@media (max-width: 900px) {
  .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status { display: none; }
  .top h1 { flex: 1; }
}
@media (max-width: 700px) {
  .relay { gap: 14px; padding-left: 14px; padding-right: 14px; }
  .deck { flex-direction: column; align-items: center; }
  .tempo { align-items: center; }
  .btn-row { justify-content: center; }
  .reel { width: 170px; height: 170px; order: -1; }
  .neon { min-width: 54px; font-size: 16px; } .neon.wide { min-width: 70px; } .neon.play { min-width: 130px; }
  .btn-row { gap: 8px; } .barbeat b { font-size: 24px; }
  .slot { min-height: 0; }
  .knob { width: 64px; height: 64px; }
  .knob i { margin-top: -20px; width: 10px; height: 10px; margin-left: -5px; }
  .hint { white-space: normal; flex-wrap: wrap; }
  .linked, .top h1 { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  .slot.wait .knob::before, .slot.pinged .knob { animation: none; }
}
