/* Visual theme adapted from https://github.com/shotplates-design/pixel-music */
@font-face {
  font-family: "Press Start 2P";
  src: url("../fonts/PressStart2P-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Silkscreen";
  src: url("../fonts/Silkscreen-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #1a1030;
  --bg-2: #2a1848;
  --panel: #3b2266;
  --ink: #f6e7c1;
  --muted: #cbb6e6;
  --pink: #ff4d8d;
  --cyan: #4dffe0;
  --yellow: #ffe14a;
  --green: #8dff6a;
  --red: #ff6b5a;
  --line: #140a22;
  --shadow: 4px 4px 0 var(--line);
  --display: "Press Start 2P", monospace;
  --body: "Silkscreen", monospace;
  --nav-h: 58px;
  --player-h: 168px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #0e0818;
  background-size: 8px 8px, 8px 8px, auto;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  touch-action: manipulation;
}

body {
  display: flex;
  justify-content: center;
}

button, input, label { font: inherit; color: inherit; touch-action: manipulation; }

button { cursor: pointer; }

img, .art { image-rendering: pixelated; }

.app {
  width: min(480px, 100%);
  height: 100%;
  max-height: 100dvh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  border-left: 4px solid var(--line);
  border-right: 4px solid var(--line);
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: calc(12px + var(--safe-t)) 12px 12px;
  background: var(--bg-2);
  border-bottom: 4px solid var(--line);
  z-index: 6;
}

.logo {
  margin: 0;
  font-family: var(--display);
  font-size: 14px;
  line-height: 1.5;
  color: var(--yellow);
}

.tag, .usage, .help, .meta, .time, .fine {
  margin: 0;
  color: var(--muted);
}

.usage {
  border: 4px solid var(--line);
  background: var(--bg);
  box-shadow: var(--shadow);
  padding: 8px;
  color: var(--cyan);
  white-space: pre-line;
  text-align: right;
  max-width: 46%;
}

.stage {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hint {
  margin: 0;
  padding: 12px;
  background: var(--panel);
  border: 4px solid var(--line);
  box-shadow: var(--shadow);
}

.view {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 12px 12px calc(24px + var(--safe-b));
  overflow-anchor: none;
  display: grid;
  gap: 12px;
  align-content: start;
}

.nav, .player {
  position: relative;
  flex: 0 0 auto;
  width: auto;
  background: var(--bg-2);
  border-top: 4px solid var(--line);
  z-index: 6;
}

.nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch;
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 6px 8px var(--safe-b);
  gap: 6px;
}

.player {
  min-height: var(--player-h);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  padding: 8px 10px 10px;
}

.nav-btn, .btn, .icon-btn {
  min-height: 44px;
  border: 4px solid var(--line);
  box-shadow: var(--shadow);
  background: var(--yellow);
  color: var(--line);
  padding: 8px 10px;
  text-transform: uppercase;
}

.nav-btn {
  background: var(--bg);
  color: var(--ink);
  box-shadow: none;
  flex: 1;
  min-width: 0;
  font-size: 10px;
  padding: 8px 4px;
}
.nav-btn[aria-current="page"] { background: var(--pink); color: var(--line); }

.btn.pink { background: var(--pink); }
.btn.cyan { background: var(--cyan); }
.btn.ghost { background: var(--bg); color: var(--ink); }
.btn.danger { background: var(--red); }
.btn:active, .nav-btn:active, .icon-btn:active {
  box-shadow: 0 0 0 var(--line);
}

.btn:disabled, .icon-btn:disabled { opacity: 0.55; }

.icon-btn { min-width: 72px; }

.player-open {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
  text-transform: none;
}

.player-copy { min-width: 0; display: grid; }
.player-title, .track-title, .panel h2, .sheet h2 {
  font-family: var(--display);
  font-size: 11px;
  line-height: 1.55;
  color: var(--ink);
}
.player-title, .track-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.art {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 4px solid var(--line);
  background: var(--panel);
  object-fit: cover;
}

.art.lg { width: min(240px, 70vw); height: min(240px, 70vw); }

.art-empty {
  background-color: #3b2266;
  background-image:
    linear-gradient(var(--pink), var(--pink)),
    linear-gradient(var(--yellow), var(--yellow)),
    linear-gradient(var(--cyan), var(--cyan));
  background-size: 10px 22px, 18px 10px, 28px 8px;
  background-position: 18px 8px, 8px 28px, 8px 8px;
  background-repeat: no-repeat;
}

.transport {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rights {
  margin: 12px 12px 0;
  flex: 0 0 auto;
}

.seek { grid-column: 1 / -1; display: block; }
.seek input {
  width: 100%;
  accent-color: var(--pink);
  height: 22px;
}
.time { grid-column: 1 / -1; display: flex; justify-content: space-between; }

.stack, .row-actions, .form, .inline { display: flex; gap: 8px; flex-wrap: wrap; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.view > h2, .section-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 11px;
  line-height: 1.55;
}
.checks { display: grid; gap: 8px; width: 100%; }
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px;
  background: var(--bg-2);
  border: 4px solid var(--line);
}
.check input { width: 22px; height: 22px; accent-color: var(--pink); }
.field { display: grid; gap: 6px; flex: 1 1 100%; }
.form input, .inline input, .field input {
  flex: 1 1 160px;
  min-height: 44px;
  font-size: 16px;
  padding: 8px;
  background: #12091c;
  border: 4px solid var(--line);
  box-shadow: var(--shadow);
}

button.panel { width: 100%; text-align: left; color: var(--ink); }
.panel, .card, .notice {
  background: var(--bg-2);
  border: 4px solid var(--line);
  box-shadow: var(--shadow);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.card { grid-template-columns: 48px 1fr; align-items: center; }
.card .body { min-width: 0; display: grid; gap: 4px; }
.card .row-actions { grid-column: 1 / -1; }

.notice { background: #4a2048; }
.notice.ok { background: #1d4638; }

.help { font-size: 15px; }

.sheet, .modal {
  position: fixed;
  inset: 0;
  z-index: 8;
  background: rgba(8, 4, 16, 0.72);
  display: grid;
  align-items: end;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding-top: var(--safe-t);
}

.sheet[hidden], .modal[hidden], .hint[hidden], .toast[hidden] { display: none; }

.sheet-card, .modal-card {
  width: min(480px, 100%);
  background: var(--bg);
  border: 4px solid var(--line);
  box-shadow: var(--shadow);
  padding: 16px 16px calc(16px + var(--safe-b));
  display: grid;
  gap: 12px;
  justify-items: center;
}

.sheet-card { text-align: center; }
.sheet-card .seek, .sheet-card .time, .sheet-card .stack { width: 100%; }

.modal-card { justify-items: stretch; margin: auto 0 0; }

.toast {
  position: absolute;
  top: calc(64px + var(--safe-t));
  left: 12px;
  right: 12px;
  width: auto;
  z-index: 9;
  background: var(--cyan);
  color: var(--line);
  border: 4px solid var(--line);
  box-shadow: var(--shadow);
  padding: 10px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

@media (min-width: 520px) {
  .app { height: 100%; max-height: 100dvh; }
}
