* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #050506; color: #f4f4f6; font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", sans-serif; -webkit-font-smoothing: antialiased; }
canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }
body.playing { cursor: pointer; }

#find { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 32px)); z-index: 5; transition: opacity .6s; }
#find.away { opacity: 0; pointer-events: none; }
#q { width: 100%; padding: 16px 4px; border: none; border-bottom: 1px solid rgba(255,255,255,.3); background: transparent; color: #fff; font: inherit; font-size: 22px; font-weight: 300; letter-spacing: .01em; text-align: center; outline: none; transition: border-color .3s; text-shadow: 0 1px 12px rgba(0,0,0,.4); }
#q::placeholder { color: rgba(255,255,255,.6); }
#q:focus { border-color: rgba(255,255,255,.75); }

#results { list-style: none; margin: 14px 0 0; padding: 0; max-height: 52vh; overflow-y: auto; scrollbar-width: none; }
#results::-webkit-scrollbar { display: none; }
#results li { display: flex; align-items: center; gap: 14px; padding: 8px 10px; border-radius: 10px; cursor: pointer; opacity: 0; transform: translateY(4px); animation: in .3s forwards; background: rgba(0,0,0,.22); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); margin-bottom: 4px; }
#results li:hover, #results li.sel { background: rgba(0,0,0,.4); }
#results img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex: none; }
#results b { display: block; font-weight: 450; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#results span { display: block; font-size: 12px; color: rgba(255,255,255,.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#results li div { min-width: 0; }
@keyframes in { to { opacity: 1; transform: none; } }
#msg { min-height: 1.2em; margin: 14px 0 0; text-align: center; font-size: 13px; color: rgba(255,255,255,.7); }

/* pause / play glyph that appears in the middle and fades away */
#center { position: fixed; left: 50%; top: 50%; width: 84px; height: 84px; margin: -42px 0 0 -42px; z-index: 6; pointer-events: none; opacity: 0; border-radius: 50%; background: rgba(0,0,0,.28); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#center.flash { animation: glyph 1.1s ease-out forwards; }
#center::before, #center::after { content: ''; position: absolute; top: 27px; width: 9px; height: 30px; border-radius: 3px; background: #fff; }
#center::before { left: 29px; }
#center::after { left: 46px; }
#center.play::before { left: 33px; top: 26px; width: 0; height: 0; border-radius: 0; background: none; border-left: 26px solid #fff; border-top: 16px solid transparent; border-bottom: 16px solid transparent; }
#center.play::after { display: none; }
#center.loading::before, #center.loading::after { display: none; }
#center.loading { opacity: 1; background: none; backdrop-filter: none; border: 2px solid rgba(255,255,255,.18); border-top-color: rgba(255,255,255,.85); width: 34px; height: 34px; margin: -17px 0 0 -17px; animation: spin .8s linear infinite; }
@keyframes glyph { 0% { opacity: 0; transform: scale(.85); } 15% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.12); } }
@keyframes spin { to { transform: rotate(360deg); } }

#done { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; gap: 28px; z-index: 5; animation: fade .6s forwards; opacity: 0; }
@keyframes fade { to { opacity: 1; } }
#done button { background: none; border: none; color: rgba(255,255,255,.85); font: inherit; font-size: 17px; font-weight: 300; letter-spacing: .04em; cursor: pointer; padding: 6px 2px; border-bottom: 1px solid transparent; text-shadow: 0 1px 12px rgba(0,0,0,.5); }
#done button:hover { color: #fff; border-color: rgba(255,255,255,.65); }

#timer { position: fixed; left: 0; right: 0; bottom: 0; height: 2px; z-index: 4; background: rgba(255,255,255,.06); }
#timer i { display: block; height: 100%; width: 0; background: rgba(255,255,255,.55); }
#clip { display: none; }
body.dragging::after { content: 'Drop your clip'; position: fixed; inset: 0; display: grid; place-items: center; font-size: 20px; font-weight: 300; letter-spacing: .08em; background: rgba(0,0,0,.55); z-index: 9; }

/* Keep the same minimal layout within phone safe areas and the on-screen keyboard. */
html, body { overscroll-behavior: none; }
canvas { height: 100dvh; }
#vid { opacity: 0; transition: opacity .35s ease; }
#vid.ready { opacity: 1; }
#find { top: calc(var(--view-top, 0px) + var(--view-height, 100dvh) / 2); max-height: calc(var(--view-height, 100dvh) - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
#q { flex: none; }
#results { min-height: 0; max-height: 52dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#msg { flex: none; }
#results li { min-height: 56px; touch-action: manipulation; }
#done { width: max-content; max-width: calc(100vw - 32px); gap: 24px; }
#done button { min-height: 48px; padding: 12px 8px; touch-action: manipulation; white-space: nowrap; }
#done button:focus-visible, #results li:focus-visible { outline: 1px solid rgba(255,255,255,.8); outline-offset: 4px; }
@media (max-height: 460px) { #q { padding: 8px 4px; } #results { margin-top: 8px; } #msg { margin-top: 4px; } }
