:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --panel-2: #232733;
  --text: #e7e9ee;
  --muted: #9aa0ad;
  --border: #2c3140;
  --primary: #4f46e5;
  --danger: #e5484d;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.4rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}

.brand { font-size: 1.25rem; margin: 0; letter-spacing: 0.3px; }

.profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.profile label { color: var(--muted); font-size: 0.85rem; }

select, input[type="text"], input[type="file"] {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.95rem;
}

.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--primary); border-color: var(--primary); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); }

main { padding: 1.4rem; max-width: 1100px; margin: 0 auto; }

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

.pad {
  position: relative;
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.8rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.06s ease, box-shadow 0.12s ease;
  user-select: none;
  overflow: hidden;
  word-break: break-word;
}
.pad:hover { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); }
.pad:active, .pad.playing { transform: scale(0.96); }
.pad.playing { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.55); }

.pad .hotkey {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.85;
  background: rgba(0, 0, 0, 0.28);
  padding: 1px 6px;
  border-radius: 6px;
}

.pad .pad-controls {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  gap: 4px;
}
.editing .pad .pad-controls { display: flex; }
.editing .pad { cursor: grab; }
.pad .icon-btn {
  border: none;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border-radius: 6px;
  width: 24px;
  height: 24px;
  font-size: 0.8rem;
  cursor: pointer;
  line-height: 1;
}
.pad .icon-btn:hover { background: rgba(0, 0, 0, 0.6); }

.add-pad {
  aspect-ratio: 1 / 1;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  transition: border-color 0.15s, color 0.15s;
}
.add-pad:hover { border-color: var(--primary); color: var(--text); }
.add-pad .plus { font-size: 1.8rem; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
}

.hidden { display: none !important; }

/* Dialogs */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 1.4rem;
  width: min(420px, 92vw);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog h2 { margin: 0 0 1rem; font-size: 1.15rem; }

.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
.field span { font-size: 0.82rem; color: var(--muted); }
.field-row { display: flex; gap: 0.9rem; }
.field-row .field { flex: 1; }
input[type="color"] { width: 100%; height: 38px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); cursor: pointer; }

.error { color: var(--danger); font-size: 0.85rem; min-height: 1.1em; margin: 0 0 0.6rem; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
}

.drag-over { outline: 2px dashed var(--primary); outline-offset: 2px; }
