:root {
  --bg: #14161b;
  --panel: #1e2129;
  --panel-hi: #272b36;
  --text: #e8eaf0;
  --muted: #8a90a2;
  --accent: #6c8cff;
  --rec: #ff4d5e;
  /* Text on the bright pad, accent and record colors: white on them doesn't
     reach the 4.5:1 contrast WCAG asks for, this dark ink does on all of them. */
  --on-color: #10131a;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Buttons get display: inline-flex below, which would otherwise beat the
   browser's own rule for the hidden attribute. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--panel-hi);
}

h1 { margin: 0; font-size: 22px; letter-spacing: 0.5px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.3px; }
.brand img { display: block; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* A clear focus ring for keyboard users (menus style their own). */
:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

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

[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  color: var(--on-color);
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  user-select: none;
}
button:hover, .button:hover { filter: brightness(1.12); }
.secondary { background: var(--panel-hi); color: var(--text); }

.icon {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon .solid, .icon.solid { fill: currentColor; stroke: none; }
/* The icon set only holds symbols: it must take no space (the hidden
   attribute doesn't hide <svg> elements). */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.danger { background: transparent; color: var(--muted); }
.danger:hover { color: var(--rec); }

.record { background: var(--panel-hi); color: var(--text); }
.record .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--rec); }
.record.recording { background: var(--rec); color: var(--on-color); }
.record.recording .dot { background: var(--on-color); border-radius: 2px; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

.timer { font-variant-numeric: tabular-nums; color: var(--rec); min-width: 3em; }

.volume { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

main { flex: 1; padding: 24px; }

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 16px 24px 0;
  padding: 12px 16px;
  border: 1px solid rgba(245, 185, 66, 0.35);
  border-radius: var(--radius);
  background: rgba(245, 185, 66, 0.1);
}
.notice > .icon { color: #f5b942; }
.notice p { flex: 1 1 280px; margin: 0; }
.notice-actions { display: flex; gap: 8px; }

.empty { color: var(--muted); text-align: center; margin-top: 15vh; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}

.pad {
  position: relative;
  border-radius: var(--radius);
}

.pad .play {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 130px;
  padding: 8px 12px;
  background: var(--pad-color, var(--accent));
  color: var(--on-color);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.06s;
}
.pad .play:active, .pad.playing .play { transform: scale(0.97); }
.pad.playing .play { filter: brightness(1.25); }

.pad .name { font-weight: 600; font-size: 16px; text-align: center; padding: 0 8px; word-break: break-word; }
.pad .duration { font-size: 12px; font-weight: 500; }
.pad .badges {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  display: flex;
  gap: 4px;
}
.pad .key, .pad .loop-badge {
  height: 22px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
}
.pad .key {
  min-width: 24px;
  padding: 3px 6px;
  font: 600 12px/16px ui-monospace, monospace;
}
.pad .key:empty { display: none; }
.pad .loop-badge { width: 22px; padding: 4px; display: none; }
.pad.looping .loop-badge { display: block; }

/* Shown while waiting for the key to assign */
.pad .assign-hint {
  position: absolute;
  inset: 0;
  color: var(--text);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(15, 17, 23, 0.82);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.pad.assigning .assign-hint { display: flex; }
.pad.assigning .play { outline: 2px solid #f5b942; outline-offset: 2px; }

.pad .more {
  color: var(--on-color);
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  opacity: 0.85;
}
.pad .more:hover, .pad .more[aria-expanded="true"] { background: rgba(0, 0, 0, 0.45); opacity: 1; }
.pad.assigning .more { display: none; }
.pad .progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  width: 0;
  background: rgba(255, 255, 255, 0.85);
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 24px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--panel-hi);
}
.repo-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.repo-link:hover { color: var(--text); }

kbd {
  color: var(--text);
  font: 12px ui-monospace, monospace;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--panel-hi);
  border: 1px solid #3a3f4d;
}

/* Trim editor */
.modal {
  padding: 20px 24px;
  border: 1px solid var(--panel-hi);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.6); }
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.import-dialog { width: min(480px, calc(100vw - 32px)); }

.trim-dialog { width: min(900px, calc(100vw - 32px)); }
.trim-dialog .hint { margin: 0 0 14px; color: var(--muted); font-size: 13px; }

.wave-wrap {
  position: relative;
  height: 160px;
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.wave-wrap canvas { display: block; width: 100%; height: 100%; }
.wave-wrap .shade { position: absolute; top: 0; bottom: 0; background: rgba(0, 0, 0, 0.6); pointer-events: none; }
.wave-wrap .handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 14px;
  margin-left: -7px;
  cursor: ew-resize;
}
.wave-wrap .handle::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 5px;
  width: 4px;
  border-radius: 2px;
  background: #f5b942;
}
.wave-wrap .playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; pointer-events: none; }

.trim-times {
  display: flex;
  justify-content: space-between;
  margin: 10px 0 16px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.trim-times strong { color: var(--text); }

.dialog-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.dialog-buttons .spacer { flex: 1; }

/* Popup menus: the pad actions and the language list */
.menu {
  position: fixed;
  z-index: 20;
  min-width: 200px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--panel-hi);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.menu[hidden] { display: none; }
.menu button, .menu li {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: start;
  white-space: nowrap;
  cursor: pointer;
}
.menu button:hover, .menu button:focus-visible, .menu li:hover, .menu li:focus-visible {
  background: var(--panel-hi);
  filter: none;
  outline: none;
}
.menu .icon { color: var(--muted); }
.menu .check { margin-inline-start: auto; visibility: hidden; color: var(--accent); }
.menu [aria-checked="true"] .check, .menu [aria-selected="true"] .check { visibility: visible; }
.menu .danger, .menu .danger .icon { color: #ff6b7a; }
.menu hr { margin: 6px 4px; border: 0; border-top: 1px solid var(--panel-hi); }

.flag {
  width: 22px;
  height: 15px;
  flex: none;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
  object-fit: cover;
}
#languageButton .chevron { width: 14px; height: 14px; color: var(--muted); }

/* Reordering */
/* Swipes scroll the page (a long press lifts a pad instead); no callout or
   text selection on a long press. */
.pad .play { touch-action: pan-x pan-y; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.pad.drag-placeholder { opacity: 0.3; }
.drag-ghost {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  transform: scale(1.05) rotate(-1.5deg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
body.reordering { cursor: grabbing; user-select: none; }

/* People who asked their system for less motion get no tilting, pulsing or
   pressed-pad animations. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .drag-ghost, .pad .play:active, .pad.playing .play { transform: none; }
}
body.reordering * { cursor: grabbing !important; }

/* ?debug panel */
.debug-panel {
  position: fixed;
  inset-inline: 8px;
  bottom: 8px;
  z-index: 50;
  margin: 0;
  padding: 8px 10px;
  max-height: 40vh;
  overflow: auto;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.85);
  color: #9effa0;
  font: 11px/1.4 ui-monospace, monospace;
  white-space: pre-wrap;
  pointer-events: none;
}
