/* LighthousePlayer - Metro (Windows Phone style) tile UI */
:root {
  --bg: #000;
  --fg: #fff;
  --dim: #9a9a9a;
  --tile: 150px;
  --half: 72px;
  --gap: 6px;
  --c-blue: #1ba1e2;
  --c-navy: #2d5be3;
  --c-red: #e51400;
  --c-green: #339933;
  --c-orange: #f09609;
  --c-purple: #a200ff;
  --c-teal: #00aba9;
  --c-indigo: #6a00ff;
  --c-gray: #3a3a3a;
  --c-lime: #8cbf26;
  --c-pink: #e671b8;
  --range: rgba(162, 0, 255, 0.14);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: "Segoe UI", "Segoe WP", system-ui, sans-serif;
  background: var(--bg); color: var(--fg);
  -webkit-text-size-adjust: 100%;
}
body { display: flex; flex-direction: column; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { font: inherit; }

/* ---------- page title ---------- */
#pagehead { flex: 0 0 auto; padding: 6px 12px 0; display: flex; align-items: baseline; gap: 14px; min-width: 0; }
#scoreTitle { font-size: 26px; font-weight: 300; letter-spacing: .5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#scoreSub { font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }

/* ---------- tiles ---------- */
#tiles {
  flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: var(--gap); padding: 6px 12px 8px;
  max-height: 62vh; overflow-y: auto; align-content: flex-start; scrollbar-width: thin;
}
.tgroup { display: flex; flex-wrap: wrap; gap: var(--gap); align-content: flex-start; align-items: flex-start; }
.tcol { display: flex; flex-direction: column; gap: var(--gap); }
.tile {
  position: relative; display: block; width: var(--tile); height: var(--tile); padding: 8px 10px;
  background: var(--c-blue); color: #fff; border: 0; border-radius: 0; text-align: left; cursor: pointer;
  overflow: hidden; transition: transform .08s, opacity .15s, background .15s; flex: 0 0 auto;
  font-size: 15px; font-weight: 600; line-height: 1.15;
}
.tile:active { transform: scale(.955); }
.tile:disabled { opacity: .35; cursor: default; transform: none; }
.tile .tl { position: absolute; left: 10px; bottom: 7px; right: 8px; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .ico { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); font-size: 54px; line-height: 1; }
.tile.small { height: var(--half); }
.tile.small .ico { font-size: 30px; top: 40%; }
.tile.mini { width: var(--half); height: var(--half); padding: 6px; }
.tile.mini .tl { left: 6px; right: 4px; bottom: 5px; font-size: 12px; }
.tile.wide { width: calc(var(--tile) * 2 + var(--gap)); }
.tile .num { position: absolute; left: 10px; top: 8px; font-size: 68px; font-weight: 300; line-height: 1; letter-spacing: -2px; font-variant-numeric: tabular-nums; }
.tile .num.small { font-size: 40px; top: 14px; letter-spacing: -1px; }
#tempoTile .num { font-size: 40px; top: 16px; letter-spacing: -1px; }
#tempoTile > span.sub { top: 70px; }
.tile > span.sub { position: absolute; left: 11px; top: 84px; font-size: 13px; font-weight: 400; color: rgba(255,255,255,.85); line-height: 1.25; }
.tile.info { cursor: default; }
.tile.info:active { transform: none; }
.tile .badge { position: absolute; right: 8px; top: 6px; background: rgba(0,0,0,.35); font-size: 13px; padding: 1px 7px; min-width: 22px; text-align: center; }
.tile .presets { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; }
.tile .presets span { display: block; background: rgba(0,0,0,.28); font-size: 14px; padding: 4px 0; width: 44px; text-align: center; font-weight: 600; }
.tile .presets span.on { background: #fff; color: var(--c-blue); }
.tile .presets span:active { background: rgba(0,0,0,.5); }

.c-blue { background: var(--c-blue); } .c-navy { background: var(--c-navy); } .c-red { background: var(--c-red); }
.c-green { background: var(--c-green); } .c-orange { background: var(--c-orange); } .c-purple { background: var(--c-purple); }
.c-teal { background: var(--c-teal); } .c-indigo { background: var(--c-indigo); } .c-gray { background: var(--c-gray); }
.tile.tog:not(.on) { background: var(--c-gray); color: #cfcfcf; }
.tile.tog.on::after { content: "\2713"; position: absolute; right: 8px; top: 4px; font-size: 18px; }
#playBtn.playing { background: var(--c-orange); }
#practiceBtn.playing { background: var(--c-green); }

/* voices */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.tile.mode.on { background: var(--c-teal); color: #fff; }
#g-voices { width: 100%; flex-wrap: nowrap; }
#voices { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: flex-start; flex: 1 1 0; min-width: 0; }
.vrow { display: flex; gap: var(--gap); align-items: flex-start; }
.vsub { display: flex; gap: var(--gap); position: relative; padding-left: 10px; }
.vsub::before { content: ""; position: absolute; left: 2px; top: 8px; bottom: 8px; width: 4px; background: var(--vc); opacity: .8; }
.tile.vtile { --vc: #1ba1e2; background: var(--vc); width: var(--tile); height: var(--tile); }
.tile.vtile .tl { font-size: 20px; bottom: 8px; }
.tile.vtile.sub { width: var(--half); background: color-mix(in srgb, var(--vc) 70%, white 30%); }
.tile.vtile.sub .tl { font-size: 17px; left: 7px; right: 4px; bottom: 6px; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.tile.vtile.sub .tl.long { font-size: 11px; white-space: normal; line-height: 1.1; }
.tile.vtile.lv60 { background: color-mix(in srgb, var(--vc) 55%, #222 45%); }
.tile.vtile.lv60::after { content: "60%"; position: absolute; right: 6px; top: 4px; font-size: 12px; background: rgba(0,0,0,.35); padding: 1px 5px; }
.tile.vtile.lv0 { background: #2a2a2a; color: #8a8a8a; }
.tile.vtile.lv0 .tl { text-decoration: line-through; }
.tile.vtile.lvmix { background: repeating-linear-gradient(135deg, var(--vc) 0 8px, color-mix(in srgb, var(--vc) 45%, #222 55%) 8px 16px); }
.tile.vtile .eye {
  position: absolute; right: 0; top: 0; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.3); font-size: 15px; cursor: pointer;
}
.tile.vtile .eye.off { background: #e51400; color: #fff; }
.tile.vtile .eye.off::after { content: "\2715"; font-size: 12px; margin-left: 1px; }

/* ---------- flyouts ---------- */
.flyout {
  position: absolute; z-index: 30; top: 48px; right: 12px; width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 70px);
  background: #1f1f1f; color: #fff; padding: 0 0 10px; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.7); border-left: 6px solid var(--c-blue);
}
.flyout .fhead { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-size: 22px; font-weight: 300; text-transform: lowercase; letter-spacing: .5px; }
.flyout .fclose { background: transparent; border: 0; color: #fff; font-size: 20px; width: 44px; height: 44px; cursor: pointer; }
.flyout .fhint { padding: 8px 14px; font-size: 13px; color: var(--dim); line-height: 1.5; }
.prow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; border-top: 1px solid #2d2d2d; }
.seg { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill { background: #3a3a3a; color: #fff; border: 0; min-height: 44px; min-width: 44px; padding: 0 16px; font-size: 15px; font-weight: 600; cursor: pointer; }
.pill.on { background: var(--c-blue); }
.val { font-size: 16px; font-weight: 600; min-width: 56px; text-align: center; }
input[type=range] { width: 170px; accent-color: var(--c-blue); }

/* files list */
.flist { display: flex; flex-direction: column; gap: 6px; padding: 0 14px; }
.ftile { display: flex; align-items: stretch; background: var(--c-indigo); min-height: 64px; }
.ftile .fmain { flex: 1 1 auto; padding: 8px 12px; cursor: pointer; min-width: 0; }
.ftile .ftitle { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ftile .fmeta { font-size: 12px; color: rgba(255,255,255,.8); }
.ftile .fdel { width: 56px; background: rgba(0,0,0,.3); border: 0; color: #fff; font-size: 18px; cursor: pointer; }
.ftile .fdel.confirm { background: var(--c-red); font-size: 13px; width: 90px; }
.ftile.current { outline: 3px solid #fff; outline-offset: -3px; }
.flist .fempty { padding: 16px 0; color: var(--dim); }

/* keypad */
.keypad { width: 320px; border-left-color: var(--c-purple); }
.kpval { font-size: 40px; font-weight: 300; padding: 0 14px; min-height: 52px; display: flex; align-items: center; }
.kpval .caret { display: inline-block; width: 2px; height: 36px; background: #fff; margin-left: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { to { visibility: hidden; } }
.kphint { padding: 0 14px 8px; font-size: 13px; color: var(--dim); min-height: 20px; }
.kpgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 14px; }
.kpgrid button { height: 60px; background: #3a3a3a; color: #fff; border: 0; font-size: 24px; font-weight: 300; cursor: pointer; }
.kpgrid button:active { background: #555; }
.kpgrid .kp-ok { grid-column: span 2; background: var(--c-green); font-weight: 600; }
.kpgrid .kp-x { background: #2c2c2c; }

/* ---------- score (single horizontal line) ---------- */
#scoreArea { flex: 1 1 auto; min-height: 120px; overflow: auto; position: relative; background: #fff; color: #000; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#scoreWrap { position: relative; display: inline-block; min-width: 100%; min-height: 100%; }
#osmd { position: relative; padding: 10px 40vw 20px 10px; }
#osmd svg { display: block; }
#overlay { position: absolute; left: 10px; top: 10px; pointer-events: none; }
#overlay .rng { position: absolute; background: var(--range); }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #666; font-size: 20px; pointer-events: none; }
.empty .big { font-size: 64px; }
.empty .dim { font-size: 15px; }
body.dragover #scoreArea { outline: 4px dashed var(--c-purple); outline-offset: -8px; }

.status {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 50;
  background: #1ba1e2; color: #fff; padding: 10px 18px; font-size: 15px; font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,.5); max-width: 90vw;
}
.status.error { background: var(--c-red); }

@media (max-width: 700px) {
  :root { --tile: 120px; --half: 57px; }
  .tile .num { font-size: 52px; }
  .tile > span.sub { top: 66px; font-size: 12px; }
  .tile .ico { font-size: 42px; }
  #scoreTitle { font-size: 20px; }
}

/* ---------- PIN lock ---------- */
.lock { position: fixed; inset: 0; z-index: 100; background: #000; display: flex; align-items: center; justify-content: center; transition: opacity .3s; }
.lock.open { opacity: 0; pointer-events: none; }
.lockbox { width: 300px; text-align: center; }
.locktitle { font-size: 30px; font-weight: 300; letter-spacing: .5px; }
.locksub { font-size: 14px; color: var(--dim); margin-bottom: 18px; text-transform: lowercase; }
.pindots { display: flex; justify-content: center; gap: 14px; margin-bottom: 22px; }
.pindots i { width: 18px; height: 18px; border: 2px solid #fff; background: transparent; display: block; transition: background .1s; }
.pindots i.on { background: var(--c-blue); border-color: var(--c-blue); }
.kpgrid.pin { grid-template-columns: repeat(3, 1fr); padding: 0; }
.kpgrid.pin button { height: 64px; font-size: 26px; }
.lockmsg { min-height: 24px; margin-top: 14px; color: var(--c-red); font-weight: 600; }
.shake { animation: shake .4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

/* ---------- voice rows v2: 2x2 row tile with 1x1 voice tiles stacked at its right edge ---------- */
.tile.vtile.big { width: var(--tile); height: var(--tile); }
.tile.vtile.big > .tl { right: calc(var(--half) + 14px); font-size: 20px; bottom: 8px; }
.tile.vtile.big > .eye { right: auto; left: 0; }
.vstack { position: absolute; right: 0; top: 0; display: flex; flex-direction: column; gap: var(--gap); }
.vstack .tile.vtile.sub { width: var(--half); height: var(--half); margin: 0; }
.tile.vtile.sub { background: color-mix(in srgb, var(--vc) 62%, white 38%); }
.tile.vtile.lv50 { background: color-mix(in srgb, var(--vc) 55%, #222 45%); }
.tile.vtile.lv50::after { content: "50%"; position: absolute; left: 6px; top: 4px; font-size: 11px; background: rgba(0,0,0,.4); padding: 1px 4px; }
.tile.vtile.big.lv50::after { left: auto; right: calc(var(--half) + 14px); top: 6px; }
.tile.vtile.sub.lv50 { background: color-mix(in srgb, var(--vc) 35%, #333 65%); }
.tile.vtile.lv60 { background: color-mix(in srgb, var(--vc) 55%, #222 45%); }
.tile.vtile.big.lvmix { background: repeating-linear-gradient(135deg, var(--vc) 0 10px, color-mix(in srgb, var(--vc) 45%, #222 55%) 10px 20px); }
div.tile.vtile { cursor: pointer; }

/* ---------- v3 tweaks: metronome tile among voices, count-in / intonation states ---------- */
.tile.vtile.metro .mico { position: absolute; right: 10px; top: 8px; font-size: 34px; }
.tile.vtile.metro.lv0 .mico { opacity: .4; }
#intonationBtn.playing { background: var(--c-green); }
#countInBtn.playing { background: var(--c-orange); }
.c-lime { background: var(--c-lime); }
.tile.vtile.big:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }

/* ---------- v4: play tile with position, context menu, metronome tile ---------- */
#playBtn .num { font-size: 64px; top: 10px; }
#playBtn > span.sub { top: 82px; font-size: 14px; }
#playBtn .pico { position: absolute; right: 10px; top: 8px; font-size: 26px; line-height: 1; }
#playBtn.playing { background: var(--c-orange); }
#playBtn:disabled .num { opacity: .5; }
.ctxmenu {
  position: fixed; z-index: 45; background: #1f1f1f; color: #fff; min-width: 240px;
  border-left: 6px solid var(--c-purple); box-shadow: 0 10px 40px rgba(0,0,0,.7);
}
.ctxmenu .ctxhead { padding: 10px 16px 6px; font-size: 20px; font-weight: 300; text-transform: lowercase; letter-spacing: .5px; color: var(--dim); }
.ctxmenu button { display: block; width: 100%; text-align: left; background: transparent; color: #fff; border: 0; padding: 14px 18px; font-size: 18px; font-weight: 600; cursor: pointer; }
.ctxmenu button:active { background: #3a3a3a; }
.tile.vtile.metro .mico { position: absolute; right: 8px; top: 6px; font-size: 22px; }
.tile.vtile.metro.lv0 .mico { opacity: .4; }
#intonationBtn.playing { background: var(--c-green); }
#countInBtn.playing { background: var(--c-orange); }
.c-lime { background: var(--c-lime); }
.tile.vtile.big:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }

/* ---------- range markers: vertical start / end lines ---------- */
#overlay .rline { position: absolute; width: 6px; margin-left: -3px; border-radius: 3px; z-index: 3; }
#overlay .rline.start { background: var(--c-green); box-shadow: 0 0 0 1px rgba(255,255,255,.7); }
#overlay .rline.end { background: var(--c-red); box-shadow: 0 0 0 1px rgba(255,255,255,.7); }
#overlay .rflag { position: absolute; top: -4px; font: 700 14px/1 "Segoe UI", sans-serif; color: #fff; padding: 5px 8px; white-space: nowrap; }
#overlay .rline.start .rflag { left: 4px; background: var(--c-green); }
#overlay .rline.end .rflag { right: 4px; background: var(--c-red); }

#overlay { z-index: 3; }
#osmd img { z-index: 2 !important; }

/* ---------- own playback cursor: thin vertical line ---------- */
#overlay #cursorLine { position: absolute; width: 3px; margin-left: -1px; background: var(--c-purple); box-shadow: 0 0 0 1px rgba(255,255,255,.6); border-radius: 2px; z-index: 4; }

/* ---------- range beat steppers next to Poliranje ---------- */
.rgrid { display: grid; grid-template-columns: repeat(3, var(--half)); grid-auto-rows: var(--half); gap: var(--gap); }
.tile.mini .ico { font-size: 24px; top: 34%; }
.tile.mini .tl { font-size: 13px; }
