* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #05070d; color: #e8eef7;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  /* the canvas handles every pinch and swipe itself; stop the browser zooming or bouncing the page */
  touch-action: none; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}
button, input, a { touch-action: manipulation; }
#c { position: fixed; inset: 0; display: block; cursor: grab; touch-action: none; }
#c.dragging { cursor: grabbing; }
#c.hover { cursor: pointer; }

#top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; pointer-events: none;
}
#top h1 {
  margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; opacity: .75;
}
#search-wrap { pointer-events: auto; }
#search {
  width: 200px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.35);
  color: inherit; font: inherit; font-size: 14px; outline: none;
}
#search:focus { border-color: rgba(255,255,255,.5); }

#readout {
  position: fixed; top: 54px; left: 0; right: 0; text-align: center; pointer-events: none;
  text-shadow: 0 2px 12px rgba(0,0,0,.6);
}
#readout-main { font-size: 30px; font-weight: 300; letter-spacing: .02em; }
#readout-exp { font-size: 14px; opacity: .65; margin-top: 2px; }

#info {
  position: fixed; right: 18px; top: 120px; width: 300px; max-width: calc(100vw - 32px);
  padding: 18px 20px 16px; border-radius: 14px;
  background: rgba(10,14,24,.82); border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
#info h2 { margin: 0 60px 4px 0; font-size: 20px; font-weight: 600; }
#info-size { font-size: 13px; opacity: .7; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
#info p { margin: 0; font-size: 14px; line-height: 1.5; opacity: .9; }
/* heart and close share one fixed box so their glyphs line up */
#info-close, #info-heart {
  position: absolute; top: 10px; width: 28px; height: 28px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; background: none; line-height: 1; cursor: pointer;
}
#info-close { right: 10px; color: inherit; font-size: 22px; opacity: .6; }
#info-close:hover { opacity: 1; }
#info-heart { right: 40px; color: #ff6b8a; font-size: 19px; opacity: .8; }
#info-heart:hover { opacity: 1; transform: scale(1.15); }
#info-heart.on { opacity: 1; }
#info-src {
  display: inline-block; margin-top: 10px; font-size: 12px; color: #8cc8ff; text-decoration: none;
}
#info-src:hover { text-decoration: underline; }
#info-src[hidden] { display: none; }

#controls {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  width: min(760px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 999px;
  background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.12);
}
#controls button {
  flex: none; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06);
  color: inherit; font-size: 14px; cursor: pointer;
}
#controls button:hover { background: rgba(255,255,255,.14); }
#controls button.active { background: rgba(120,190,255,.35); border-color: rgba(120,190,255,.7); }
#track { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
#slider { width: 100%; margin: 0; accent-color: #8cc8ff; cursor: pointer; }
/* hearted objects sit on the scale bar as tiny pictures at their own size; 8px = thumb radius */
#hearts { position: absolute; left: 8px; right: 8px; bottom: 100%; height: 0; }
#hearts > .pin, #hearts > .folder { position: absolute; bottom: 1px; transform: translateX(-50%); }
#hearts button {
  position: relative; display: block; min-width: 0; width: auto; height: auto; padding: 0;
  border: 0; border-radius: 0; background: none; cursor: pointer;
}
#hearts button:hover { background: none; }
#hearts canvas { display: block; filter: drop-shadow(0 1px 3px rgba(0,0,0,.8)); transition: transform .15s; }
#hearts .pin:hover canvas, #hearts .pin:focus-visible canvas { transform: scale(1.6); }
#hearts .tip {
  position: absolute; bottom: 135%; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: #fff; white-space: nowrap; padding: 3px 8px; border-radius: 6px;
  background: rgba(10,14,24,.92); opacity: 0; pointer-events: none; transition: opacity .15s;
}
#hearts .pin:hover .tip, #hearts .pin:focus-visible .tip { opacity: 1; }

/* objects too close together share a folder: a little stack of cards with a count */
#hearts .face { isolation: isolate; }
#hearts .face::before, #hearts .face::after {
  content: ""; position: absolute; inset: -1px; z-index: -1; border-radius: 4px;
  background: rgba(140,200,255,.16); border: 1px solid rgba(255,255,255,.3);
}
#hearts .face::before { transform: translate(2px, -2px); }
#hearts .face::after { transform: translate(4px, -4px); opacity: .6; }
#hearts .count {
  position: absolute; top: -8px; right: -10px; min-width: 11px; height: 11px; padding: 0 2px;
  border-radius: 6px; background: #ff6b8a; color: #fff; font-size: 8px; font-weight: 700;
  line-height: 11px; text-align: center;
}
#hearts .fan {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  display: flex; align-items: flex-end; gap: 8px; padding: 6px 8px 10px;
  border-radius: 8px; background: rgba(10,14,24,.92); border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
#hearts .folder:hover .fan, #hearts .folder:focus-within .fan, #hearts .folder.open .fan { opacity: 1; pointer-events: auto; }
#hearts .folder:hover .face, #hearts .folder.open .face { opacity: .4; }

#hint {
  position: fixed; bottom: 10px; left: 0; right: 0; text-align: center;
  font-size: 12px; opacity: .45; pointer-events: none; padding: 0 16px;
}

@media (max-width: 560px) {
  #top h1 { font-size: 12px; }
  #search { width: 140px; }
  #readout-main { font-size: 24px; }
  #info { top: auto; bottom: calc(112px + env(safe-area-inset-bottom)); right: 16px; }
  #controls button#btn-play-in, #controls button#btn-play-out { display: none; }
  #controls { bottom: calc(40px + env(safe-area-inset-bottom)); }
  #hint { bottom: calc(10px + env(safe-area-inset-bottom)); font-size: 11px; }
}
/* bigger slider thumb for fingers */
@media (pointer: coarse) {
  #slider { height: 28px; }
  #controls button { min-width: 40px; height: 40px; }
}
